28
28
* @summary Checks that there is no an inconsistence in combo box
29
29
* behavior when user points an item in combo popup
30
30
* by mouse and then uses UP/DOWN keys.
31
- * @library ../../regtesthelpers
32
- * @build Util
33
- * @author Mikhail Lapshin
34
31
* @run main bug6236162
35
32
*/
36
33
@@ -44,15 +41,20 @@ public class bug6236162 {
44
41
private static JFrame frame ;
45
42
private static JComboBox combo ;
46
43
private static MyComboUI comboUI ;
44
+ private static Robot robot ;
47
45
48
46
public static void main (String [] args ) throws Exception {
47
+ robot = new Robot ();
48
+ robot .setAutoDelay (100 );
49
49
try {
50
50
UIManager .setLookAndFeel (UIManager .getCrossPlatformLookAndFeelClassName ());
51
51
SwingUtilities .invokeAndWait (new Runnable () {
52
52
public void run () {
53
53
createAndShowGUI ();
54
54
}
55
55
});
56
+ robot .waitForIdle ();
57
+ robot .delay (1000 );
56
58
test ();
57
59
System .out .println ("Test passed" );
58
60
} finally {
@@ -74,15 +76,14 @@ private static void createAndShowGUI() {
74
76
frame .setDefaultCloseOperation (JFrame .EXIT_ON_CLOSE );
75
77
frame .setLocationRelativeTo (null );
76
78
frame .setVisible (true );
79
+ frame .toFront ();
77
80
}
78
81
79
82
private static void test () throws AWTException {
80
- Robot robot = new Robot ();
81
- robot .setAutoDelay (50 );
82
83
83
84
// Open popup menu
84
- robot .waitForIdle ( );
85
- Util . hitKeys ( robot , KeyEvent .VK_DOWN );
85
+ robot .keyPress ( KeyEvent . VK_DOWN );
86
+ robot . keyRelease ( KeyEvent .VK_DOWN );
86
87
87
88
// Move mouse to the first popup menu item
88
89
robot .waitForIdle ();
@@ -98,7 +99,8 @@ private static void test() throws AWTException {
98
99
99
100
// Select the second popup menu item
100
101
robot .waitForIdle ();
101
- Util .hitKeys (robot , KeyEvent .VK_DOWN );
102
+ robot .keyPress (KeyEvent .VK_DOWN );
103
+ robot .keyRelease (KeyEvent .VK_DOWN );
102
104
103
105
robot .waitForIdle ();
104
106
JList list = comboUI .getComboPopup ().getList ();
0 commit comments