Skip to content

Commit dea94f4

Browse files
committed
8328300: Convert PrintDialogsTest.java from Applet to main program
Reviewed-by: psadhukhan, dnguyen
1 parent d32746e commit dea94f4

File tree

2 files changed

+75
-62
lines changed

2 files changed

+75
-62
lines changed

test/jdk/java/awt/Modal/PrintDialogsTest/PrintDialogsTest.html

Lines changed: 0 additions & 44 deletions
This file was deleted.

test/jdk/java/awt/Modal/PrintDialogsTest/PrintDialogsTest.java

Lines changed: 75 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -25,21 +25,76 @@
2525
/*
2626
* @test
2727
* @bug 8055836 8057694 8055752
28-
* @summary Check if Print and Page Setup dialogs lock other windows;
28+
* @summary Check if Print and Page Setup dialogs block other windows;
2929
* check also correctness of modal behavior for other dialogs.
30-
*
31-
* @run applet/manual=yesno PrintDialogsTest.html
30+
* @library /java/awt/regtesthelpers
31+
* @run main/manual PrintDialogsTest
3232
*/
3333

3434

35-
import java.applet.Applet;
36-
import java.awt.*;
35+
import java.awt.BorderLayout;
36+
import java.awt.Button;
37+
import java.awt.Checkbox;
38+
import java.awt.CheckboxGroup;
39+
import java.awt.Dialog;
40+
import java.awt.Frame;
41+
import java.awt.EventQueue;
42+
import java.awt.GridLayout;
43+
import java.awt.Label;
44+
import java.awt.Panel;
3745

3846
import java.awt.event.ActionEvent;
3947
import java.awt.event.ActionListener;
4048

4149

42-
public class PrintDialogsTest extends Applet implements ActionListener {
50+
public class PrintDialogsTest extends Panel implements ActionListener {
51+
52+
static final String INSTRUCTIONS = """
53+
This test is free format, which means there is no enforced or guided sequence.
54+
55+
Please select each of
56+
(a) The dialog parent type.
57+
(b) The dialog modality type
58+
(c) The print dialog type (Print dialog or Page Setup dialog)
59+
60+
Once the choices have been made click the "Start test" button.
61+
62+
Three windows will appear
63+
(1) A Frame or a Dialog - in the case you selected "Dialog" as the parent type
64+
(2) a Window (ie an undecorated top-level)
65+
(3) A dialog with two buttons "Open" and "Finish"
66+
67+
Now check as follows whether modal blocking works as expected.
68+
Windows (1) and (2) contain a button which you should be able to press
69+
ONLY if you selected "Non-modal", or "Modeless" for modality type.
70+
In other cases window (3) will block input to (1) and (2)
71+
72+
Then push the "Open" button on the Dialog to show the printing dialog and check
73+
if it blocks the rest of the application - ie all of windows (1), (2) and (3)
74+
should ALWAYS be blocked when the print dialog is showing.
75+
Now cancel the printing dialog and check the correctness of modal blocking
76+
behavior for the Dialog again.
77+
To close all the 3 test windows please push the "Finish" button.
78+
79+
Repeat all the above for different combinations, which should include
80+
using all of the Dialog parent choices and all of the Dialog Modality types.
81+
82+
If any behave incorrectly, note the combination of choices and press Fail.
83+
84+
If all behave correctly, press Pass.
85+
""";
86+
87+
public static void main(String[] args) throws Exception {
88+
89+
PassFailJFrame.builder()
90+
.instructions(INSTRUCTIONS)
91+
.rows(35)
92+
.columns(60)
93+
.testUI(PrintDialogsTest::createUI)
94+
.testTimeOut(10)
95+
.build()
96+
.awaitAndCheck();
97+
}
4398

4499
private Button btnTest;
45100
private Checkbox cbPage, cbPrint,
@@ -48,6 +103,14 @@ public class PrintDialogsTest extends Applet implements ActionListener {
48103

49104
private CheckboxGroup groupDialog, groupParent, groupModType;
50105

106+
private static Frame createUI() {
107+
Frame frame = new Frame("Dialog Modality Testing");
108+
PrintDialogsTest test = new PrintDialogsTest();
109+
test.createGUI();
110+
frame.add(test);
111+
frame.pack();
112+
return frame;
113+
}
51114

52115
public void actionPerformed(ActionEvent e) {
53116

@@ -99,13 +162,13 @@ private void createGUI() {
99162

100163
setLayout(new BorderLayout());
101164

102-
setSize(350, 200);
103165
Panel panel = new Panel();
104-
panel.setLayout(new GridLayout(18, 1));
166+
panel.setLayout(new GridLayout(21, 1));
105167

106168
btnTest = new Button("Start test");
107169
btnTest.addActionListener(this);
108170
panel.add(btnTest);
171+
panel.add(new Label(" ")); // spacing
109172

110173

111174
panel.add(new Label("Dialog parent:"));
@@ -123,6 +186,7 @@ private void createGUI() {
123186
panel.add(cbHiddFrm);
124187
panel.add(cbDlg);
125188
panel.add(cbFrm);
189+
panel.add(new Label(" ")); // spacing
126190

127191
panel.add(new Label("Dialog modality type:"));
128192
groupModType = new CheckboxGroup();
@@ -139,7 +203,7 @@ private void createGUI() {
139203
panel.add(cbDocModal);
140204
panel.add(cbTKModal);
141205
panel.add(cbModeless);
142-
add(panel);
206+
panel.add(new Label(" ")); // spacing
143207

144208
panel.add(new Label("Print dialog type:"));
145209
groupDialog = new CheckboxGroup();
@@ -148,13 +212,6 @@ private void createGUI() {
148212
panel.add(cbPage);
149213
panel.add(cbPrint);
150214

151-
validate();
152-
setVisible(true);
153-
}
154-
155-
public void start() {
156-
try {
157-
EventQueue.invokeAndWait(this::createGUI);
158-
} catch (Exception e) {}
215+
add(panel);
159216
}
160217
}

0 commit comments

Comments
 (0)