use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class EventWhenTest method main.
public static void main(String[] args) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Frame frame = new Frame();
try {
Button b = new Button("Button");
frame.setBounds(300, 300, 300, 300);
frame.add(b);
frame.setVisible(true);
toolkit.realSync();
Robot robot = new Robot();
robot.mouseMove((int) frame.getLocationOnScreen().getX() + 150, (int) frame.getLocationOnScreen().getY() + 150);
eventsCount = 0;
System.out.println("Clicking mouse...");
for (int i = 0; i < 300 && !failed; i++) {
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
Thread.sleep(10);
b.setLabel("Click: " + i);
}
if (eventsCount == 0) {
throw new RuntimeException("No events were received");
}
if (failed) {
throw new RuntimeException("Test failed.");
}
System.out.println("Clicking mouse done: " + eventsCount + " events.");
b.requestFocusInWindow();
toolkit.realSync();
eventsCount = 0;
System.out.println("Typing a key...");
for (int i = 0; i < 300 && !failed; i++) {
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_A);
Thread.sleep(10);
b.setLabel("Type: " + i);
}
System.out.println("Key typing done: " + eventsCount + " events.");
if (eventsCount == 0) {
throw new RuntimeException("No events were received");
}
if (failed) {
throw new RuntimeException("Test failed.");
}
System.out.println("Success!");
} finally {
frame.dispose();
}
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class DeadKeySystemAssertionDialog method main.
public static void main(String[] args) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Frame frame = new Frame();
frame.setSize(300, 200);
TextField textField = new TextField();
frame.add(textField);
frame.setVisible(true);
toolkit.realSync();
textField.requestFocus();
toolkit.realSync();
// Check that the system assertion dialog does not block Java
Robot robot = new Robot();
robot.setAutoDelay(50);
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_A);
toolkit.realSync();
frame.setVisible(false);
frame.dispose();
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class TextEventSequenceTest method test.
private static void test(String test) {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
createAndShowGUI(test);
toolkit.realSync();
initCounts();
t.setText("Hello ");
toolkit.realSync();
t.append("World! !");
toolkit.realSync();
t.insert("from Roger Pham", 13);
toolkit.realSync();
t.replaceRange("Java Duke", 18, 28);
toolkit.realSync();
checkCounts(0, 4);
initCounts();
t.setText("");
toolkit.realSync();
t.setText("");
toolkit.realSync();
t.setText("");
toolkit.realSync();
checkCounts(1, 0);
initCounts();
tf.setText("Hello There!");
toolkit.realSync();
checkCounts(0, 1);
initCounts();
tf.setText("");
toolkit.realSync();
tf.setText("");
toolkit.realSync();
tf.setText("");
toolkit.realSync();
checkCounts(1, 0);
f.dispose();
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class Test6827032 method main.
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
Robot robot = new Robot();
robot.setAutoDelay(50);
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
Component previewPanel = Util.findSubComponent(cc, "javax.swing.colorchooser.DefaultPreviewPanel");
point = previewPanel.getLocationOnScreen();
}
});
point.translate(5, 5);
robot.mouseMove(point.x, point.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class bug8057893 method main.
public static void main(String[] args) throws Exception {
Robot robot = new Robot();
robot.setAutoDelay(50);
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
EventQueue.invokeAndWait(() -> {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
JComboBox<String> comboBox = new JComboBox<>(new String[] { "one", "two" });
comboBox.setEditable(true);
comboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if ("comboBoxEdited".equals(e.getActionCommand())) {
isComboBoxEdited = true;
}
}
});
frame.add(comboBox);
frame.pack();
frame.setVisible(true);
comboBox.requestFocusInWindow();
});
toolkit.realSync();
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_A);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
toolkit.realSync();
if (!isComboBoxEdited) {
throw new RuntimeException("ComboBoxEdited event is not fired!");
}
}
Aggregations