use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class ShowPopupAfterHidePopupTest method main.
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new MetalLookAndFeel());
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
frame = new JFrame("Popup Menu of JComboBox");
comboBox = new JComboBox(new String[] { "Item1", "Item2", "Item3" });
frame.getContentPane().add(comboBox);
frame.pack();
frame.setVisible(true);
}
});
final SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
comboBox.showPopup();
comboBox.hidePopup();
comboBox.showPopup();
}
});
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
popupIsVisible = comboBox.isPopupVisible();
frame.dispose();
}
});
if (!popupIsVisible) {
throw new RuntimeException("Calling hidePopup() affected the next call to showPopup().");
}
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class Test7194184 method testKeyBoardAccess.
private static void testKeyBoardAccess() throws Exception {
Robot robot = new Robot();
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeLater(new Test7194184());
toolkit.realSync();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
selectedColor = colorChooser.getColor();
Component recentSwatchPanel = Util.findSubComponent(colorChooser, "RecentSwatchPanel");
if (recentSwatchPanel == null) {
throw new RuntimeException("RecentSwatchPanel not found");
}
recentSwatchPanel.requestFocusInWindow();
}
});
toolkit.realSync();
// Tab to move the focus to MainSwatch
Util.hitKeys(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB);
// Select the color on right
Util.hitKeys(robot, KeyEvent.VK_RIGHT);
Util.hitKeys(robot, KeyEvent.VK_RIGHT);
Util.hitKeys(robot, KeyEvent.VK_SPACE);
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
frame.dispose();
if (selectedColor == colorChooser.getColor()) {
throw new RuntimeException("JColorChooser misses keyboard accessibility");
}
}
});
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class Test7024235 method main.
public static void main(String[] args) throws Exception {
Test7024235 test = new Test7024235();
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
UIManager.setLookAndFeel(info.getClassName());
test.test();
toolkit.realSync();
Thread.sleep(1000);
test.test();
}
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class bug4670486 method main.
public static void main(String[] args) throws Throwable {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
robot.setAutoDelay(250);
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
JFrame frame = new JFrame("Test");
frame.setContentPane(createPanel(frame));
frame.setJMenuBar(createMenuBar());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
});
toolkit.realSync();
// Change the default button to
// force a call to BasicRootPaneUI.updateDefaultButtonBindings()
Util.hitKeys(robot, KeyEvent.VK_TAB);
// If the bug exists, then as soon as the menu appears,
// the VK_ENTER, VK_DOWN, VK_UP and VK_ESC will have no
// effect.
Util.hitMnemonics(robot, KeyEvent.VK_U);
Util.hitKeys(robot, KeyEvent.VK_ENTER);
toolkit.realSync();
checkAction();
Util.hitMnemonics(robot, KeyEvent.VK_U);
Util.hitKeys(robot, KeyEvent.VK_DOWN);
Util.hitKeys(robot, KeyEvent.VK_ENTER);
toolkit.realSync();
checkAction();
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class bug6542335 method main.
public static void main(String[] args) throws Exception {
final Robot robot = new Robot();
robot.setAutoDelay(10);
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
final Rectangle[] thumbBounds = new Rectangle[1];
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
final JFrame frame = new JFrame("bug6542335");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
sb = new JScrollBar(0, 0, 1, 0, 1);
ui = new MyScrollBarUI();
sb.setUI(ui);
sb.setPreferredSize(new Dimension(200, 17));
DefaultBoundedRangeModel rangeModel = new DefaultBoundedRangeModel();
rangeModel.setMaximum(100);
rangeModel.setMinimum(0);
rangeModel.setExtent(50);
rangeModel.setValue(50);
sb.setModel(rangeModel);
frame.add(sb, BorderLayout.NORTH);
frame.setSize(200, 100);
frame.setVisible(true);
}
});
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
thumbBounds[0] = new Rectangle(ui.getThumbBounds());
Point l = sb.getLocationOnScreen();
robot.mouseMove(l.x + (int) (0.75 * sb.getWidth()), l.y + sb.getHeight() / 2);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
});
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
Rectangle newThumbBounds = ui.getThumbBounds();
if (!thumbBounds[0].equals(newThumbBounds)) {
throw new RuntimeException("Test failed.\nOld bounds: " + thumbBounds[0] + "\nNew bounds: " + newThumbBounds);
}
}
});
}
Aggregations