|
1 | 1 | /* |
2 | | - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
@@ -46,36 +46,25 @@ public class ComboPopupTest { |
46 | 46 | private volatile Point p = null; |
47 | 47 | private volatile Dimension d = null; |
48 | 48 |
|
49 | | - void blockTillDisplayed(JComponent comp) throws Exception { |
50 | | - while (p == null) { |
51 | | - try { |
52 | | - SwingUtilities.invokeAndWait(() -> { |
53 | | - p = comp.getLocationOnScreen(); |
54 | | - d = comboBox.getSize(); |
55 | | - }); |
56 | | - } catch (IllegalStateException e) { |
57 | | - try { |
58 | | - Thread.sleep(1000); |
59 | | - } catch (InterruptedException ie) { |
60 | | - } |
61 | | - } |
62 | | - } |
63 | | - } |
64 | | - |
65 | 49 | public static void main(String[] args) throws Exception { |
66 | 50 | new ComboPopupTest(); |
67 | 51 | } |
68 | 52 |
|
69 | 53 | public ComboPopupTest() throws Exception { |
70 | 54 | try { |
71 | 55 | Robot robot = new Robot(); |
72 | | - robot.setAutoDelay(200); |
| 56 | + robot.setAutoDelay(100); |
73 | 57 | SwingUtilities.invokeAndWait(() -> start()); |
74 | | - blockTillDisplayed(comboBox); |
| 58 | + robot.delay(1000); |
| 59 | + SwingUtilities.invokeAndWait(() -> { |
| 60 | + p = comboBox.getLocationOnScreen(); |
| 61 | + d = comboBox.getSize(); |
| 62 | + }); |
| 63 | + robot.waitForIdle(); |
| 64 | + robot.mouseMove(p.x + d.width - 1, p.y + d.height/2); |
75 | 65 | robot.waitForIdle(); |
76 | | - robot.mouseMove(p.x + d.width-1, p.y + d.height/2); |
77 | | - robot.mousePress(InputEvent.BUTTON1_MASK); |
78 | | - robot.mouseRelease(InputEvent.BUTTON1_MASK); |
| 66 | + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); |
| 67 | + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); |
79 | 68 | robot.waitForIdle(); |
80 | 69 |
|
81 | 70 | System.out.println("popmenu visible " + comboBox.isPopupVisible()); |
|
0 commit comments