mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-03 10:20:57 +00:00
8371365: Update javax/swing/JFileChooser/bug4759934.java to use Util.findComponent()
Reviewed-by: aivanov, dnguyen, azvegint
This commit is contained in:
parent
e5c72937af
commit
78db38f140
@ -31,10 +31,11 @@
|
||||
* @run main bug4759934
|
||||
*/
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dialog;
|
||||
import java.awt.Point;
|
||||
import java.awt.Robot;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
@ -72,8 +73,10 @@ public class bug4759934 {
|
||||
robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK);
|
||||
robot.delay(500);
|
||||
|
||||
robot.keyPress(KeyEvent.VK_ESCAPE);
|
||||
robot.keyRelease(KeyEvent.VK_ESCAPE);
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
JButton cancelBtn = findCancelButton(jfc);
|
||||
cancelBtn.doClick();
|
||||
});
|
||||
robot.delay(500);
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
@ -121,4 +124,11 @@ public class bug4759934 {
|
||||
dlg.setLocation(fr.getX() + fr.getWidth() + 10, fr.getY());
|
||||
dlg.setVisible(true);
|
||||
}
|
||||
|
||||
private static JButton findCancelButton(final Container container) {
|
||||
Component result = Util.findComponent(container,
|
||||
c -> c instanceof JButton button
|
||||
&& "Cancel".equals(button.getText()));
|
||||
return (JButton) result;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user