Search in sources :

Example 36 with SunToolkit

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

the class bug4361477 method main.

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

        @Override
        public void run() {
            createAndShowUI();
        }
    });
    toolkit.realSync();
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            bounds = tabbedPane.getUI().getTabBounds(tabbedPane, 0);
        }
    });
    Point location = bounds.getLocation();
    SwingUtilities.convertPointToScreen(location, tabbedPane);
    robot.mouseMove(location.x + 1, location.y + 1);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    if (!bStateChanged) {
        throw new RuntimeException("Tabbed pane state is not changed");
    }
}
Also used : SunToolkit(sun.awt.SunToolkit)

Example 37 with SunToolkit

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

the class bug7161568 method main.

public static void main(String[] args) throws Exception {
    UIManager.put("TabbedPane.selectionFollowsFocus", Boolean.FALSE);
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    Robot robot = new Robot();
    robot.setAutoDelay(50);
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            createAndShowUI();
        }
    });
    toolkit.realSync();
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            tabbedPane.requestFocus();
        }
    });
    toolkit.realSync();
    for (int i = 0; i < N; i++) {
        robot.keyPress(KeyEvent.VK_LEFT);
        robot.keyRelease(KeyEvent.VK_LEFT);
        toolkit.realSync();
    }
}
Also used : SunToolkit(sun.awt.SunToolkit)

Example 38 with SunToolkit

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

the class bug7170310 method main.

public static void main(String[] args) throws Exception {
    try {
        UIManager.setLookAndFeel(new MetalLookAndFeel());
        SwingUtilities.invokeAndWait(bug7170310::createAndShowUI);
        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        toolkit.realSync();
        for (int i = 0; i < TABS_NUMBER; i++) {
            SwingUtilities.invokeAndWait(bug7170310::addTab);
            toolkit.realSync();
        }
        SwingUtilities.invokeAndWait(bug7170310::check);
        if (exception != null) {
            System.out.println("Test failed: " + exception.getMessage());
            throw exception;
        } else {
            System.out.printf("Test passed");
        }
    } finally {
        frame.dispose();
    }
}
Also used : SunToolkit(sun.awt.SunToolkit) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel)

Example 39 with SunToolkit

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

the class bug4530474 method main.

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

        @Override
        public void run() {
            createAndShowGUI();
        }
    });
    toolkit.realSync();
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            boolean passed = false;
            Point p = jep.getLocationOnScreen();
            Dimension d = jep.getSize();
            int x0 = p.x;
            int y = p.y + d.height / 3;
            StringBuilder builder = new StringBuilder("Test color: ");
            builder.append(TEST_COLOR.toString());
            builder.append(" resut colors: ");
            for (int x = x0; x < x0 + d.width; x++) {
                Color color = robot.getPixelColor(x, y);
                builder.append(color);
                if (TEST_COLOR.equals(color)) {
                    passed = true;
                    break;
                }
            }
            if (!passed) {
                throw new RuntimeException("Test Fail. " + builder.toString());
            }
        }
    });
}
Also used : SunToolkit(sun.awt.SunToolkit)

Example 40 with SunToolkit

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

the class bug7165725 method execute.

public void execute(final String urlStr, final GoldenElement goldenElement) throws Exception {
    System.out.println();
    System.out.println("***** TEST: " + urlStr + " *****");
    System.out.println();
    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            try {
                editorPane = new JEditorPane();
                editorPane.setEditorKit(new HTMLEditorKit() {

                    public Document createDefaultDocument() {
                        AbstractDocument doc = (AbstractDocument) super.createDefaultDocument();
                        doc.setAsynchronousLoadPriority(-1);
                        return doc;
                    }
                });
                editorPane.setPage(new URL(urlStr));
            } catch (IOException ex) {
                throw new RuntimeException("Test failed", ex);
            }
            editorPane.setEditable(false);
            JScrollPane scroller = new JScrollPane();
            JViewport vp = scroller.getViewport();
            vp.add(editorPane);
            add(scroller, BorderLayout.CENTER);
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            setSize(400, 400);
            setLocationRelativeTo(null);
            setVisible(true);
        }
    });
    ((SunToolkit) SunToolkit.getDefaultToolkit()).realSync();
    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            HTMLDocument doc = (HTMLDocument) editorPane.getDocument();
            doc.dump(System.out);
            goldenElement.checkStructureEquivalence((AbstractElement) doc.getDefaultRootElement());
            dispose();
        }
    });
    System.out.println();
    System.out.println("*********************************");
    System.out.println();
}
Also used : AbstractDocument(javax.swing.text.AbstractDocument) AbstractElement(javax.swing.text.AbstractDocument.AbstractElement) HTMLDocument(javax.swing.text.html.HTMLDocument) SunToolkit(sun.awt.SunToolkit) HTMLEditorKit(javax.swing.text.html.HTMLEditorKit) IOException(java.io.IOException) URL(java.net.URL)

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