Search in sources :

Example 76 with SunToolkit

use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.

the class bug7004134 method main.

public static void main(String[] args) throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            label = new JLabel("A JLabel used as object for an HTML-formatted tooltip");
            label.setToolTipText("<html><body bgcolor=FFFFE1>An HTML-formatted ToolTip</body></html>");
            frame = new JFrame();
            frame.add(label);
            frame.pack();
            frame.setVisible(true);
        }
    });
    ((SunToolkit) SunToolkit.getDefaultToolkit()).realSync();
    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            ToolTipManager toolTipManager = ToolTipManager.sharedInstance();
            toolTipManager.setInitialDelay(0);
            toolTipManager.mouseMoved(new MouseEvent(label, 0, 0, 0, 0, 0, 0, false));
        }
    });
    Thread.sleep(500);
    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            toolTipWidth = getTipWindow().getWidth();
            frame.dispose();
        }
    });
    Thread thread = new Thread(new ThreadGroup("Some ThreadGroup"), new Runnable() {

        public void run() {
            SunToolkit.createNewAppContext();
            try {
                SwingUtilities.invokeAndWait(new Runnable() {

                    public void run() {
                        frame = new JFrame();
                        frame.add(label);
                        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                        frame.pack();
                        frame.setVisible(true);
                    }
                });
                ((SunToolkit) SunToolkit.getDefaultToolkit()).realSync();
                SwingUtilities.invokeAndWait(new Runnable() {

                    public void run() {
                        ToolTipManager toolTipManager = ToolTipManager.sharedInstance();
                        toolTipManager.setInitialDelay(0);
                        toolTipManager.mouseMoved(new MouseEvent(label, 0, 0, 0, 0, 0, 0, false));
                    }
                });
                Thread.sleep(500);
                SwingUtilities.invokeAndWait(new Runnable() {

                    public void run() {
                        int newToolTipWidth = getTipWindow().getWidth();
                        frame.dispose();
                        if (toolTipWidth != newToolTipWidth) {
                            throw new RuntimeException("Tooltip width is different. Initial: " + toolTipWidth + ", new: " + newToolTipWidth);
                        }
                    }
                });
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    });
    thread.start();
    thread.join();
}
Also used : MouseEvent(java.awt.event.MouseEvent) SunToolkit(sun.awt.SunToolkit)

Example 77 with SunToolkit

use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.

the class bug6824395 method main.

public static void main(String[] args) throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            JFrame frame = new JFrame("testing");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JEditorPane editorPane = new JEditorPane();
            String str = "hello\n";
            for (int i = 0; i < 5; i++) {
                str += str;
            }
            editorPane.setText(str);
            JLayer<JEditorPane> editorPaneLayer = new JLayer<JEditorPane>(editorPane);
            LayerUI<JComponent> layerUI = new LayerUI<JComponent>();
            editorPaneLayer.setUI(layerUI);
            scrollPane = new JScrollPane(editorPaneLayer);
            scrollPane.setPreferredSize(new Dimension(200, 250));
            frame.add(scrollPane);
            frame.setSize(200, 200);
            frame.pack();
            frame.setVisible(true);
        }
    });
    toolkit.realSync();
    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            if (scrollPane.getViewportBorderBounds().width != scrollPane.getViewport().getView().getWidth()) {
                throw new RuntimeException("Wrong component's width!");
            }
        }
    });
}
Also used : SunToolkit(sun.awt.SunToolkit) LayerUI(javax.swing.plaf.LayerUI)

Example 78 with SunToolkit

use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.

the class bug7138665 method main.

public static void main(String[] args) throws Exception {
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            JOptionPane pane = new JOptionPane("Enter value", JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null);
            pane.setWantsInput(true);
            JDialog dialog = pane.createDialog(null, "My Dialog");
            dialog.setVisible(true);
            Object result = pane.getValue();
            if (result == null || ((Integer) result).intValue() != JOptionPane.OK_OPTION) {
                throw new RuntimeException("Invalid result: " + result);
            }
            System.out.println("Test bug7138665 passed");
        }
    });
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    toolkit.realSync();
    Robot robot = new Robot();
    robot.setAutoDelay(100);
    robot.keyPress(KeyEvent.VK_ENTER);
    robot.keyRelease(KeyEvent.VK_ENTER);
    toolkit.realSync();
}
Also used : SunToolkit(sun.awt.SunToolkit)

Example 79 with SunToolkit

use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.

the class bug4966112 method main.

public static void main(String[] args) throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    robot = new Robot();
    robot.setAutoDelay(100);
    createAndShowButton();
    toolkit.realSync();
    setClickPoint(testButton);
    clickMouse(InputEvent.BUTTON1_MASK);
    clickMouse(InputEvent.BUTTON2_MASK);
    clickMouse(InputEvent.BUTTON3_MASK);
    toolkit.realSync();
    closeFrame();
    if (popupButton == NO_MOUSE_BUTTON) {
        System.out.println("Test can't identify the popup trigger button. Test skipped");
        return;
    }
    setButtonMask();
    // Test Split Pane
    createAndShowSplitPane();
    toolkit.realSync();
    clickMouse(jsp);
    toolkit.realSync();
    closeFrame();
    if (!shown) {
        throw new RuntimeException("Popup was not shown on splitpane");
    }
    // Test Spinner
    createAndShowSpinner();
    toolkit.realSync();
    clickMouse(spin);
    toolkit.realSync();
    closeFrame();
    if (!shown) {
        throw new RuntimeException("Popup was not shown on spinner");
    }
    // Test File Chooser
    createAndShowFileChooser();
    toolkit.realSync();
    clickMouse(filec);
    toolkit.realSync();
    Util.hitKeys(robot, KeyEvent.VK_ESCAPE);
    toolkit.realSync();
    Util.hitKeys(robot, KeyEvent.VK_ESCAPE);
    toolkit.realSync();
    closeFrame();
    if (!shown) {
        throw new RuntimeException("Popup was not shown on filechooser");
    }
}
Also used : SunToolkit(sun.awt.SunToolkit)

Example 80 with SunToolkit

use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.

the class bug6209975 method main.

public static void main(String[] args) throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    Robot robot = new Robot();
    robot.setAutoDelay(500);
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            createAndShowGUI();
        }
    });
    toolkit.realSync();
    Point clickPoint = getButtonClickPoint();
    robot.mouseMove(clickPoint.x, clickPoint.y);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    toolkit.realSync();
    clickPoint = getMenuClickPoint();
    robot.mouseMove(clickPoint.x, clickPoint.y);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    toolkit.realSync();
    if (RO1.itsValue <= RO2.itsValue) {
        throw new RuntimeException("Offset if the second icon is invalid.");
    }
}
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