42
42
43
43
public class Test6541987 implements Runnable {
44
44
private static Robot robot ;
45
+ private static JFrame frame ;
45
46
46
- public static void main (String [] args ) throws AWTException {
47
- robot = new Robot ();
48
- // test escape after selection
49
- start ();
50
- click (KeyEvent .VK_ESCAPE );
51
- robot .waitForIdle ();
52
- // test double escape after editing
53
- start ();
54
- click (KeyEvent .VK_1 );
55
- click (KeyEvent .VK_0 );
56
- click (KeyEvent .VK_ESCAPE );
57
- click (KeyEvent .VK_ESCAPE );
58
- robot .waitForIdle ();
59
- // all windows should be closed
60
- for (Window window : Window .getWindows ()) {
61
- if (window .isVisible ()) {
62
- throw new Error ("found visible window: " + window .getName ());
47
+ public static void main (String [] args ) throws Exception {
48
+ try {
49
+ robot = new Robot ();
50
+ robot .setAutoDelay (100 );
51
+ // test escape after selection
52
+ start ();
53
+ click (KeyEvent .VK_ESCAPE );
54
+ robot .waitForIdle ();
55
+ // test double escape after editing
56
+ start ();
57
+ click (KeyEvent .VK_1 );
58
+ click (KeyEvent .VK_0 );
59
+ click (KeyEvent .VK_ESCAPE );
60
+ click (KeyEvent .VK_ESCAPE );
61
+ robot .waitForIdle ();
62
+ robot .delay (500 );
63
+ // all windows should be closed
64
+ for (Window window : Window .getWindows ()) {
65
+ if (window .isVisible ()) {
66
+ throw new Error ("found visible window: " + window .getName ());
67
+ }
68
+ }
69
+ } finally {
70
+ if (frame != null ) {
71
+ SwingUtilities .invokeAndWait (frame ::dispose );
63
72
}
64
73
}
65
74
}
@@ -85,7 +94,8 @@ private static void click(int...keys) {
85
94
86
95
public void run () {
87
96
String title = getClass ().getName ();
88
- JFrame frame = new JFrame (title );
97
+ frame = new JFrame (title );
98
+ frame .setLocationRelativeTo (null );
89
99
frame .setVisible (true );
90
100
91
101
Color color = JColorChooser .showDialog (frame , title , Color .BLACK );
0 commit comments