@@ -40,49 +40,58 @@ public class Test6256140 {
40
40
41
41
private final static String initialText = "value" ;
42
42
private final static JLabel toolTipLabel = new JLabel ("tip" );
43
+ private static JFrame frame ;
43
44
44
45
public static void main (String [] args ) throws Exception {
45
-
46
- Robot robot = new Robot ();
47
- robot .setAutoDelay (10 );
48
-
49
- SwingUtilities .invokeAndWait (new Runnable () {
50
- public void run () {
51
- createAndShowGUI ();
46
+ try {
47
+ Robot robot = new Robot ();
48
+ robot .setAutoDelay (100 );
49
+
50
+ SwingUtilities .invokeAndWait (new Runnable () {
51
+ public void run () {
52
+ createAndShowGUI ();
53
+ }
54
+ });
55
+ robot .waitForIdle ();
56
+ robot .delay (1000 );
57
+
58
+ Point point = ft .getLocationOnScreen ();
59
+ robot .mouseMove (point .x , point .y );
60
+ robot .waitForIdle ();
61
+ robot .mouseMove (point .x + 3 , point .y + 3 );
62
+ robot .waitForIdle ();
63
+
64
+ robot .keyPress (KeyEvent .VK_A );
65
+ robot .keyRelease (KeyEvent .VK_A );
66
+ robot .waitForIdle ();
67
+
68
+ if (!isTooltipShowning ()) {
69
+ throw new RuntimeException ("Tooltip is not shown" );
52
70
}
53
- });
54
- robot .waitForIdle ();
55
-
56
- Point point = ft .getLocationOnScreen ();
57
- robot .mouseMove (point .x , point .y );
58
- robot .mouseMove (point .x + 3 , point .y + 3 );
59
71
60
- robot .keyPress (KeyEvent .VK_A );
61
- robot .keyRelease (KeyEvent .VK_A );
62
- robot .waitForIdle ();
63
-
64
- if (!isTooltipShowning ()) {
65
- throw new RuntimeException ("Tooltip is not shown" );
66
- }
72
+ robot .keyPress (KeyEvent .VK_ESCAPE );
73
+ robot .keyRelease (KeyEvent .VK_ESCAPE );
74
+ robot .waitForIdle ();
67
75
68
- robot .keyPress (KeyEvent .VK_ESCAPE );
69
- robot .keyRelease (KeyEvent .VK_ESCAPE );
70
- robot .waitForIdle ();
71
-
72
- if (isTooltipShowning ()) {
73
- throw new RuntimeException ("Tooltip must be hidden now" );
74
- }
76
+ if (isTooltipShowning ()) {
77
+ throw new RuntimeException ("Tooltip must be hidden now" );
78
+ }
75
79
76
- if (isTextEqual ()) {
77
- throw new RuntimeException ("FormattedTextField must *not* cancel the updated value this time" );
78
- }
80
+ if (isTextEqual ()) {
81
+ throw new RuntimeException ("FormattedTextField must *not* cancel the updated value this time" );
82
+ }
79
83
80
- robot .keyPress (KeyEvent .VK_ESCAPE );
81
- robot .keyRelease (KeyEvent .VK_ESCAPE );
82
- robot .waitForIdle ();
84
+ robot .keyPress (KeyEvent .VK_ESCAPE );
85
+ robot .keyRelease (KeyEvent .VK_ESCAPE );
86
+ robot .waitForIdle ();
83
87
84
- if (!isTextEqual ()) {
85
- throw new RuntimeException ("FormattedTextField must cancel the updated value" );
88
+ if (!isTextEqual ()) {
89
+ throw new RuntimeException ("FormattedTextField must cancel the updated value" );
90
+ }
91
+ } finally {
92
+ if (frame != null ) {
93
+ SwingUtilities .invokeAndWait (frame ::dispose );
94
+ }
86
95
}
87
96
}
88
97
@@ -116,7 +125,7 @@ private static void createAndShowGUI() {
116
125
ToolTipManager .sharedInstance ().setDismissDelay (Integer .MAX_VALUE );
117
126
ToolTipManager .sharedInstance ().setInitialDelay (0 );
118
127
119
- final JFrame frame = new JFrame ();
128
+ frame = new JFrame ();
120
129
frame .setDefaultCloseOperation (JFrame .EXIT_ON_CLOSE );
121
130
frame .setLayout (new FlowLayout ());
122
131
0 commit comments