use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class bug8020708 method testInternalFrameMnemonic.
static void testInternalFrameMnemonic() throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
frame = new JFrame("Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 200);
JDesktopPane desktop = new JDesktopPane();
internalFrame = new JInternalFrame("Test");
internalFrame.setSize(200, 100);
internalFrame.setClosable(true);
desktop.add(internalFrame);
internalFrame.setVisible(true);
internalFrame.setMaximizable(true);
frame.getContentPane().add(desktop);
frame.setVisible(true);
}
});
toolkit.realSync();
Point clickPoint = Util.getCenterPoint(internalFrame);
robot.mouseMove(clickPoint.x, clickPoint.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
toolkit.realSync();
Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_SPACE);
toolkit.realSync();
Util.hitKeys(robot, KeyEvent.VK_C);
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
if (internalFrame.isVisible()) {
throw new RuntimeException("Close mnemonic does not work");
}
frame.dispose();
}
});
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class InternalFrameIsNotCollectedTest method sync.
public static void sync() {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
toolkit.realSync();
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class bug8002077 method runTest.
private static void runTest() throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
SwingUtilities.invokeLater(() -> fileChooserState = new JFileChooser().showSaveDialog(null));
toolkit.realSync();
Util.hitMnemonics(robot, KeyEvent.VK_N);
toolkit.realSync();
Util.hitKeys(robot, KeyEvent.VK_A);
toolkit.realSync();
Util.hitMnemonics(robot, KeyEvent.VK_S);
toolkit.realSync();
if (fileChooserState != JFileChooser.APPROVE_OPTION) {
// Close the dialog
Util.hitKeys(robot, KeyEvent.VK_ESCAPE);
toolkit.realSync();
throw new RuntimeException("Save button is not pressed!");
}
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class bug5074573 method test.
static boolean test(final Class<? extends JTextComponent> textComponentClass) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoWaitForIdle(true);
robot.setAutoDelay(50);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
initialize(textComponentClass);
}
});
toolkit.realSync();
// Remove selection from JTextField components for the Aqua Look & Feel
if (textComponent instanceof JTextField && "Aqua".equals(UIManager.getLookAndFeel().getID())) {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
Caret caret = textComponent.getCaret();
int dot = caret.getDot();
textComponent.select(dot, dot);
}
});
toolkit.realSync();
}
robot.keyPress(getCtrlKey());
robot.keyPress(KeyEvent.VK_BACK_SPACE);
robot.keyRelease(KeyEvent.VK_BACK_SPACE);
robot.keyRelease(getCtrlKey());
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
Caret caret = textComponent.getCaret();
caret.setDot(0);
}
});
toolkit.realSync();
robot.keyPress(getCtrlKey());
robot.keyPress(KeyEvent.VK_DELETE);
robot.keyRelease(KeyEvent.VK_DELETE);
robot.keyRelease(getCtrlKey());
toolkit.realSync();
return resultString.equals(getText());
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class bug7158712 method main.
public static void main(String[] args) throws Exception {
Robot robot = new Robot();
robot.setAutoDelay(500);
SynthLookAndFeel laf = new SynthLookAndFeel();
laf.load(new ByteArrayInputStream(SYNTH_XML.getBytes("UTF8")), bug7158712.class);
UIManager.setLookAndFeel(laf);
EventQueue.invokeAndWait(new Runnable() {
public void run() {
comboBox = new JComboBox<>(new String[] { "Very Looooooooooooooooooooong Text Item 1", "Item 2" });
JFrame frame = new JFrame();
frame.add(comboBox, BorderLayout.NORTH);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(new Dimension(400, 300));
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
});
((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
Point comboBoxLocation = Util.invokeOnEDT(new Callable<Point>() {
@Override
public Point call() throws Exception {
return comboBox.getLocationOnScreen();
}
});
robot.mouseMove(comboBoxLocation.x, comboBoxLocation.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
BasicComboPopup popup = (BasicComboPopup) comboBox.getAccessibleContext().getAccessibleChild(0);
Point popupPoint = popup.getLocationOnScreen();
Point comboBoxPoint = comboBox.getLocationOnScreen();
if (comboBoxPoint.x - 5 != popupPoint.x || comboBoxPoint.y + comboBox.getHeight() - 5 != popupPoint.y) {
throw new RuntimeException("Invalid popup coordinates. Popup location: " + popupPoint + ", comboBox location: " + comboBoxPoint);
}
System.out.println("Test bug7158712 passed");
}
});
}
Aggregations