Search in sources :

Example 31 with SunToolkit

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().");
    }
}
Also used : SunToolkit(sun.awt.SunToolkit)

Example 32 with SunToolkit

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");
            }
        }
    });
}
Also used : SunToolkit(sun.awt.SunToolkit) Component(java.awt.Component) Robot(java.awt.Robot)

Example 33 with SunToolkit

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();
    }
}
Also used : LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) SunToolkit(sun.awt.SunToolkit)

Example 34 with SunToolkit

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();
}
Also used : SunToolkit(sun.awt.SunToolkit)

Example 35 with SunToolkit

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);
            }
        }
    });
}
Also used : SunToolkit(sun.awt.SunToolkit)

Aggregations

SunToolkit (sun.awt.SunToolkit)120 Robot (java.awt.Robot)26 Point (java.awt.Point)9 Frame (java.awt.Frame)7 JFrame (javax.swing.JFrame)7 BufferedImage (java.awt.image.BufferedImage)5 Rectangle (java.awt.Rectangle)4 FlowLayout (java.awt.FlowLayout)3 TextField (java.awt.TextField)3 Toolkit (java.awt.Toolkit)3 MouseEvent (java.awt.event.MouseEvent)3 JTableHeader (javax.swing.table.JTableHeader)3 Component (java.awt.Component)2 KeyEvent (java.awt.event.KeyEvent)2 VolatileImage (java.awt.image.VolatileImage)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 File (java.io.File)2 IOException (java.io.IOException)2 Field (java.lang.reflect.Field)2 URL (java.net.URL)2