@@ -99,6 +99,7 @@ private void createGUI() {
9999 frame .setLocation (200 , 200 );
100100 frame .setDefaultCloseOperation (JFrame .DISPOSE_ON_CLOSE );
101101 button .setPreferredSize (new Dimension (300 , 300 ));
102+ button .setFocusPainted (false );
102103 button .addFocusListener (new FocusAdapter () {
103104 public void focusGained (FocusEvent fe ) {
104105 focusGainedLatch .countDown ();
@@ -124,9 +125,8 @@ public void runTest() throws Exception {
124125
125126 try {
126127 robot = new Robot ();
127- robot .setAutoWaitForIdle (true );
128- robot .setAutoDelay (200 );
129-
128+ robot .waitForIdle ();
129+ robot .delay (1000 );
130130 if (focusGainedLatch .await (3 , TimeUnit .SECONDS )) {
131131 System .out .println ("Button focus gained..." );
132132 } else {
@@ -142,17 +142,18 @@ public void runTest() throws Exception {
142142 // some platforms may not support maximize frame
143143 if (frame .getToolkit ().isFrameStateSupported (
144144 JFrame .MAXIMIZED_BOTH )) {
145- robot .waitForIdle ();
146145 // maximize frame from normal size
147146 frame .setExtendedState (JFrame .MAXIMIZED_BOTH );
148147 System .out .println ("Frame is maximized" );
149148 robot .waitForIdle ();
149+ robot .delay (100 );
150150
151151 if (frame .getToolkit ().isFrameStateSupported (JFrame .NORMAL )) {
152152 System .out .println ("Frame is back to normal" );
153153 // resize from maximum size to normal
154154 frame .setExtendedState (JFrame .NORMAL );
155-
155+ robot .waitForIdle ();
156+ robot .delay (100 );
156157 // capture image of JButton after resize
157158 System .out .println (
158159 "Getting image of JButton after resize..image2" );
@@ -209,9 +210,8 @@ private BufferedImage getButtonImage() {
209210 }
210211
211212 private void disposeFrame () {
212- if (frame != null ) {
213+ if (frame != null ) {
213214 frame .dispose ();
214- frame = null ;
215215 }
216216 }
217217
0 commit comments