use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class bug4743225 method main.
public static void main(String... args) throws Exception {
Robot robot = new Robot();
robot.setAutoDelay(20);
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
new bug4743225().setVisible(true);
}
});
toolkit.realSync();
// calling this method from main thread is ok
Point point = cb.getLocationOnScreen();
robot.mouseMove(point.x + 10, point.y + 10);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
if (getPopup().getList().getLastVisibleIndex() == 3) {
flag = true;
}
}
});
if (!flag) {
throw new RuntimeException("The ComboBox popup wasn't correctly updated");
}
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class ConsumedKeyTest method test.
private static void test(final int key) throws Exception {
passed = false;
try {
SwingUtilities.invokeAndWait(() -> {
frame = new JFrame();
JComboBox<String> combo = new JComboBox<>(new String[] { "one", "two", "three" });
JPanel panel = new JPanel();
panel.add(combo);
combo.requestFocusInWindow();
frame.setBounds(100, 150, 300, 100);
addAction(panel, key);
frame.add(panel);
frame.setVisible(true);
});
Robot robot = new Robot();
robot.waitForIdle();
((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
robot.keyPress(key);
robot.waitForIdle();
((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
robot.keyRelease(key);
robot.waitForIdle();
((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
if (!passed) {
throw new RuntimeException("FAILED: " + KeyEvent.getKeyText(key) + " was consumed by combo box");
}
} finally {
if (frame != null) {
frame.dispose();
}
}
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class bug7199708 method main.
public static void main(String[] args) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
final File folder = createLargeFolder();
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
SwingUtilities.invokeLater(new Runnable() {
public void run() {
fileChooser = new JFileChooser(folder);
fileChooser.showSaveDialog(null);
}
});
toolkit.realSync();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
final String detailsTooltip = UIManager.getString("FileChooser." + "detailsViewButtonToolTipText", fileChooser.getLocale());
doAction(fileChooser, new ComponentAction() {
@Override
public boolean accept(Component component) {
return (component instanceof AbstractButton) && detailsTooltip.equals(((AbstractButton) component).getToolTipText());
}
@Override
public void perform(Component component) {
((AbstractButton) component).doClick();
}
});
doAction(fileChooser, new ComponentAction() {
@Override
public boolean accept(Component component) {
return (component instanceof JTable);
}
@Override
public void perform(Component component) {
Point tableLocation = component.getLocationOnScreen();
locationX = (int) tableLocation.getX();
locationY = (int) tableLocation.getY();
width = (int) fileChooser.getBounds().getWidth();
}
});
}
});
toolkit.realSync();
int d = 25;
for (int i = 0; i < width / d; i++) {
robot.mouseMove(locationX + i * d, locationY + 5);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
toolkit.realSync();
}
robot.keyPress(KeyEvent.VK_ESCAPE);
robot.keyRelease(KeyEvent.VK_ESCAPE);
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class bug8021253 method main.
public static void main(String[] args) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(50);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
fileChooser.setSelectedFile(file);
}
});
toolkit.realSync();
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
toolkit.realSync();
if (!defaultKeyPressed) {
throw new RuntimeException("Default button is not pressed");
}
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class bug6596966 method main.
public static void main(String[] args) throws Exception {
Robot robot = new Robot();
SunToolkit toolkit = (SunToolkit) SunToolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
button = new JButton("Button");
comboBox = new JComboBox();
label = new JLabel("Label");
label.setDisplayedMnemonic('L');
label.setLabelFor(comboBox);
JPanel pnContent = new JPanel();
pnContent.add(button);
pnContent.add(label);
pnContent.add(comboBox);
frame = new JFrame();
frame.add(pnContent);
frame.pack();
frame.setVisible(true);
}
});
toolkit.realSync();
ArrayList<Integer> keys = Util.getSystemMnemonicKeyCodes();
for (int i = 0; i < keys.size(); ++i) {
robot.keyPress(keys.get(i));
}
robot.keyPress(KeyEvent.VK_L);
toolkit.realSync();
toolkit.getSystemEventQueue().postEvent(new KeyEvent(label, KeyEvent.KEY_RELEASED, EventQueue.getMostRecentEventTime(), 0, KeyEvent.VK_L, 'L'));
toolkit.realSync();
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
if (!comboBox.isFocusOwner()) {
throw new RuntimeException("comboBox isn't focus owner");
}
}
});
} finally {
robot.keyRelease(KeyEvent.VK_L);
for (int i = 0; i < keys.size(); ++i) {
robot.keyRelease(keys.get(i));
}
toolkit.realSync();
}
}
Aggregations