2121 * questions.
2222 */
2323
24- /*
25- * FrameStateTest.java
26- *
27- * summary: Checks that when setState(Frame.ICONIFIED) is called before
28- * setVisible(true) the Frame is shown in the proper iconified state.
29- * The problem was that it did not honor the initial iconic state, but
30- * instead was shown in the NORMAL state.
31- */
32-
3324import java .awt .Button ;
3425import java .awt .Checkbox ;
3526import java .awt .CheckboxGroup ;
5243 * @test
5344 * @bug 4157271
5445 * @summary Checks that when a Frame is created it honors the state it
55- * was set to. The bug was that if setState(Frame.ICONIFIED) was
56- * called before setVisible(true) the Frame would be shown in NORMAL
57- * state instead of ICONIFIED.
46+ * was set to. The bug was that if setState(Frame.ICONIFIED) was
47+ * called before setVisible(true) the Frame would be shown in NORMAL
48+ * state instead of ICONIFIED.
5849 * @library /java/awt/regtesthelpers
5950 * @build PassFailJFrame
6051 * @run main/manual FrameStateTest
@@ -68,29 +59,33 @@ This test checks that when setState(Frame.ICONIFIED) is called before
6859 setVisible(true) the Frame is shown in the proper iconified state.
6960 The problem was that it did not honor the initial iconic state, but
7061 instead was shown in the NORMAL state.
71- </p><hr/><p>
72-
62+ </p><hr/>
7363 Steps to try to reproduce this problem:
74- </p>< p>
64+ <p>
7565 Select the different options for the Frame:
7666 <ul>
77- <li><i>{Normal, Non-resizalbe }</i></li>
67+ <li><i>{Normal, Non-resizable }</i></li>
7868 <li><i>{Normal, Resizable}</i></li>
7969 <li><i>{Iconified, Resizable}</i></li>
80- <li><i>{Iconified, Non-resizalbe }</i></li>
70+ <li><i>{Iconified, Non-resizable }</i></li>
8171 </ul>
8272 After choosing the Frame's state click the
8373 Create Frame button.<br>
84- After the Frame (Frame State Test (Window2)) comes
85- up make sure the proper behavior occurred<br>
86- (Frame shown in proper state).<br>
74+ After the Frame (Frame State Test (Window2)) comes up make sure the
75+ proper behavior occurred (Frame shown in proper state).<br>
8776 Click the Dispose button to close the Frame.<br>
88-
8977 </p><hr/><p>
9078
91- Do the above steps for all the different Frame state combinations available.<br>
92- If you observe the proper behavior the test has passed, Press the Pass button.<br>
93- Otherwise the test has failed, Press the Fail button.
79+ Do the above steps for all the different Frame state combinations
80+ available.<br>
81+ For "Hide, Iconify and Show" case, the frame is hidden then iconified
82+ hence Window2 is not seen on-screen when shown as the frame is still
83+ in the ICONIFIED state. Window2 is visible on-screen when it is restored
84+ to NORMAL state as observed with "Hide, Iconify, Show and Restore" case.
85+ <br><br>
86+
87+ If you observe the proper behavior for all the combinations,
88+ press PASS else FAIL.<br>
9489 </p><p>
9590 Note: In Frame State Test (Window2) you can also chose the different
9691 buttons to see different Frame behavior.<br>An example of a problem that
@@ -106,22 +101,22 @@ After the Frame (Frame State Test (Window2)) comes
106101 Button btnDispose = new Button ("Dispose Frame" );
107102 CheckboxGroup cbgState = new CheckboxGroup ();
108103 CheckboxGroup cbgResize = new CheckboxGroup ();
109- Checkbox cbIconState = new Checkbox ("Frame state ICONIFIED" , cbgState , true );
110- Checkbox cbNormState = new Checkbox ("Frame state NORMAL" , cbgState , false );
111- Checkbox cbNonResize = new Checkbox ("Frame non-resizable " , cbgResize , false );
104+ Checkbox cbIconState = new Checkbox ("Frame State ICONIFIED" , cbgState , true );
105+ Checkbox cbNormState = new Checkbox ("Frame State NORMAL" , cbgState , false );
106+ Checkbox cbNonResize = new Checkbox ("Frame Non-Resizable " , cbgResize , false );
112107 Checkbox cbResize = new Checkbox ("Frame Resizable" , cbgResize , true );
113108
114109 CreateFrame icontst ;
115110
116111 public static void main (String [] args ) throws Exception {
117112 PassFailJFrame
118113 .builder ()
119- .title ("GetBoundsResizeTest Instructions" )
114+ .title ("Frame State and Size Test Instructions" )
120115 .instructions (INSTRUCTIONS )
121116 .testTimeOut (10 )
122- .rows (25 )
117+ .rows (27 )
123118 .columns (70 )
124- .logArea (10 )
119+ .logArea (6 )
125120 .splitUIBottom (() -> new FrameStateTest ().createPanel ())
126121 .build ()
127122 .awaitAndCheck ();
@@ -149,7 +144,7 @@ public void actionPerformed(ActionEvent evt) {
149144 if (evt .getSource () == btnCreate ) {
150145 btnCreate .setEnabled (false );
151146 btnDispose .setEnabled (true );
152- icontst =new CreateFrame (cbIconState .getState (), cbResize .getState ());
147+ icontst = new CreateFrame (cbIconState .getState (), cbResize .getState ());
153148 icontst .setVisible (true );
154149 } else if (evt .getSource () == btnDispose ) {
155150 btnCreate .setEnabled (true );
@@ -166,7 +161,7 @@ static class CreateFrame extends Frame
166161 String name = "Frame State Test" ;
167162
168163 CreateFrame (boolean iconified , boolean resizable ) {
169- setTitle ("Frame State Test (Window 2)" );
164+ setTitle ("Test Window (Window 2)" );
170165
171166 isResizable = resizable ;
172167
@@ -175,13 +170,13 @@ static class CreateFrame extends Frame
175170 ((isResizable ) ? "RESIZABLE" : "NON-RESIZABLE" ));
176171
177172 setLayout (new FlowLayout ());
178- add (b1 = new Button ("resizable " ));
179- add (b2 = new Button ("resize " ));
180- add (b3 = new Button ("iconify " ));
181- add (b4 = new Button ("iconify and restore " ));
182- add (b5 = new Button ("hide and show " ));
183- add (b6 = new Button ("hide, iconify and show " ));
184- add (b7 = new Button ("hide, iconify, show, and restore " ));
173+ add (b1 = new Button ("Resizable " ));
174+ add (b2 = new Button ("Resize " ));
175+ add (b3 = new Button ("Iconify " ));
176+ add (b4 = new Button ("Iconify and Restore " ));
177+ add (b5 = new Button ("Hide and Show " ));
178+ add (b6 = new Button ("Hide, Iconify and Show " ));
179+ add (b7 = new Button ("Hide, Iconify, Show and Restore " ));
185180 b1 .addActionListener (this );
186181 b2 .addActionListener (this );
187182 b3 .addActionListener (this );
@@ -191,10 +186,9 @@ static class CreateFrame extends Frame
191186 b7 .addActionListener (this );
192187 addWindowListener (this );
193188
194- setBounds (100 , 2 , 200 , 200 );
189+ setBounds (100 , 2 , 300 , 200 );
195190 setState (iconified ? Frame .ICONIFIED : Frame .NORMAL );
196191 setResizable (isResizable );
197- pack ();
198192 setVisible (true );
199193 }
200194
@@ -320,11 +314,11 @@ public void windowOpened(WindowEvent e) {
320314
321315 public void stateLog (String message ) {
322316 PassFailJFrame
323- .log ("[State= %d] %s %s" .formatted (getState (), name , message ));
317+ .log ("[Current State = %d] %s %s" .formatted (getState (), name , message ));
324318 }
325319
326320 public void stateLog () {
327- PassFailJFrame .log ("[State= " + getState () + "]" );
321+ PassFailJFrame .log ("[Current State = " + getState () + "]" );
328322 }
329323 }
330324}
0 commit comments