use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class bug6800513 method testFrame.
public static void testFrame(final boolean defaultLightWeightPopupEnabled, String expectedPopupClass) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
JPopupMenu.setDefaultLightWeightPopupEnabled(defaultLightWeightPopupEnabled);
createAndShowUI();
}
});
toolkit.realSync();
clickOnMenu();
toolkit.realSync();
Field getPopup = JPopupMenu.class.getDeclaredField("popup");
getPopup.setAccessible(true);
Popup popup = (Popup) getPopup.get(popupMenu);
if (popup == null) {
throw new Exception("popup is null!");
}
String className = popup.getClass().getName();
if (!className.equals(expectedPopupClass)) {
throw new Exception("popup class is: " + className + ", expected: " + expectedPopupClass);
}
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
frame.dispose();
popupMenu = null;
}
});
toolkit.realSync();
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class bug4515762 method main.
public static void main(String[] args) throws Throwable {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(250);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
JFrame frame = new JFrame("Test");
frame.setJMenuBar(createMenuBar());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
});
toolkit.realSync();
Util.hitMnemonics(robot, KeyEvent.VK_D);
toolkit.realSync();
// Press the S key many times (should not cause an action peformed)
int TIMES = 5;
for (int i = 0; i < TIMES; i++) {
Util.hitKeys(robot, KeyEvent.VK_S);
}
toolkit.realSync();
// Unique menu items.
actionExpected = true;
Util.hitMnemonics(robot, KeyEvent.VK_U);
robot.keyPress(KeyEvent.VK_S);
robot.keyRelease(KeyEvent.VK_S);
toolkit.realSync();
checkAction();
Util.hitMnemonics(robot, KeyEvent.VK_U);
robot.keyPress(KeyEvent.VK_M);
robot.keyRelease(KeyEvent.VK_M);
toolkit.realSync();
checkAction();
Util.hitMnemonics(robot, KeyEvent.VK_U);
Util.hitKeys(robot, KeyEvent.VK_T);
toolkit.realSync();
checkAction();
Util.hitMnemonics(robot, KeyEvent.VK_U);
Util.hitKeys(robot, KeyEvent.VK_W);
toolkit.realSync();
checkAction();
Util.hitMnemonics(robot, KeyEvent.VK_U);
Util.hitKeys(robot, KeyEvent.VK_U);
toolkit.realSync();
checkAction();
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class bug4171437 method main.
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
toolkit.realSync();
Robot robot = new Robot();
robot.setAutoDelay(50);
Util.hitMnemonics(robot, KeyEvent.VK_F);
Util.hitKeys(robot, KeyEvent.VK_C);
toolkit.realSync();
Thread.sleep(1000);
if (!closeActivated || customActivated) {
throw new RuntimeException("Didn't pass the muster");
}
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class bug6884066 method main.
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(20);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
// just to quickly grab a column model
JTable table = new JTable(10, 5);
header = new JTableHeader(table.getColumnModel());
checkColumn(0, "A");
JFrame frame = new JFrame("standalone header");
frame.add(header);
frame.pack();
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
});
toolkit.realSync();
Point point = header.getLocationOnScreen();
robot.mouseMove(point.x + 3, point.y + 3);
robot.mousePress(InputEvent.BUTTON1_MASK);
for (int i = 0; i < header.getWidth() - 3; i++) {
robot.mouseMove(point.x + i, point.y + 3);
}
robot.mouseRelease(InputEvent.BUTTON1_MASK);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
TableColumnModel model = header.getColumnModel();
checkColumn(model.getColumnCount() - 1, "A");
}
});
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class bug4697612 method main.
public static void main(String[] args) throws Throwable {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(100);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
createAndShowGUI();
}
});
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
text.requestFocus();
}
});
toolkit.realSync();
// 4697612: pressing PgDn + PgUp should not alter caret position
Util.hitKeys(robot, KeyEvent.VK_HOME);
Util.hitKeys(robot, KeyEvent.VK_PAGE_DOWN);
int pos0 = getTextCaretPosition();
int caretHeight = getTextCaretHeight();
fontHeight = FONT_HEIGHT;
// iterate two times, for different (even and odd) font height
for (int i = 0; i < 2; i++) {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
text.setFont(text.getFont().deriveFont(fontHeight));
}
});
frameHeight = FRAME_HEIGHT;
for (int j = 0; j < caretHeight; j++) {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
frame.setSize(FRAME_WIDTH, frameHeight);
}
});
toolkit.realSync();
Util.hitKeys(robot, KeyEvent.VK_PAGE_DOWN);
Util.hitKeys(robot, KeyEvent.VK_PAGE_UP);
toolkit.realSync();
int pos = getTextCaretPosition();
if (pos0 != pos) {
throw new RuntimeException("Failed 4697612: PgDn & PgUp keys scroll by different amounts");
}
frameHeight++;
}
fontHeight++;
}
// 6244705: pressing PgDn at the very bottom should not scroll
LookAndFeel laf = UIManager.getLookAndFeel();
if (laf.getID().equals("Aqua")) {
Util.hitKeys(robot, KeyEvent.VK_END);
} else {
Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_END);
}
toolkit.realSync();
pos0 = getScrollerViewPosition();
Util.hitKeys(robot, KeyEvent.VK_PAGE_DOWN);
toolkit.realSync();
int pos = getScrollerViewPosition();
if (pos0 != pos) {
throw new RuntimeException("Failed 6244705: PgDn at the bottom causes scrolling");
}
}
Aggregations