File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
test/jdk/javax/swing/JFileChooser Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 3131 * @run main bug4759934
3232 */
3333
34+ import java .awt .Component ;
35+ import java .awt .Container ;
3436import java .awt .Dialog ;
3537import java .awt .Point ;
3638import java .awt .Robot ;
37- import java .awt .event .KeyEvent ;
3839import java .awt .event .MouseEvent ;
3940import javax .swing .JButton ;
4041import javax .swing .JDialog ;
@@ -72,8 +73,10 @@ public static void main(String[] args) throws Exception {
7273 robot .mouseRelease (MouseEvent .BUTTON1_DOWN_MASK );
7374 robot .delay (500 );
7475
75- robot .keyPress (KeyEvent .VK_ESCAPE );
76- robot .keyRelease (KeyEvent .VK_ESCAPE );
76+ SwingUtilities .invokeAndWait (() -> {
77+ JButton cancelBtn = findCancelButton (jfc );
78+ cancelBtn .doClick ();
79+ });
7780 robot .delay (500 );
7881
7982 SwingUtilities .invokeAndWait (() -> {
@@ -121,4 +124,11 @@ private static void createDialog() {
121124 dlg .setLocation (fr .getX () + fr .getWidth () + 10 , fr .getY ());
122125 dlg .setVisible (true );
123126 }
127+
128+ private static JButton findCancelButton (final Container container ) {
129+ Component result = Util .findComponent (container ,
130+ c -> c instanceof JButton button
131+ && "Cancel" .equals (button .getText ()));
132+ return (JButton ) result ;
133+ }
124134}
You can’t perform that action at this time.
0 commit comments