Java Code Examples for sun.awt.SunToolkit#realSync()

The following examples show how to use sun.awt.SunToolkit#realSync() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ComponentTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            frame = new ComponentTest();
            frame.setVisible(true);
        }
    });
    toolkit.realSync();
    UIManager.LookAndFeelInfo[] lafs = UIManager.getInstalledLookAndFeels();
    for (final UIManager.LookAndFeelInfo laf : lafs) {
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                try {
                    UIManager.setLookAndFeel(laf.getClassName());
                } catch (Exception e) {
                    new RuntimeException(e);
                }
                SwingUtilities.updateComponentTreeUI(frame);
            }
        });
        toolkit.realSync();
    }
}
 
Example 2
Source File: bug4846413.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        Robot robot = new Robot();
        robot.setAutoDelay(50);

        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");

        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {

            public void run() {
                createAndShowGUI();
            }
        });

        toolkit.realSync();

        Point movePoint = getButtonPoint();
        robot.mouseMove(movePoint.x, movePoint.y);
        toolkit.realSync();

        long timeout = System.currentTimeMillis() + 9000;
        while (!isTooltipAdded && (System.currentTimeMillis() < timeout)) {
            try {Thread.sleep(500);} catch (Exception e) {}
        }

        checkToolTip();
    }
 
Example 3
Source File: bug4251579.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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 = htmlComponent.getLocationOnScreen();
            Dimension d = htmlComponent.getSize();
            int x0 = p.x;
            int y = p.y + d.height / 2;

            for (int x = x0; x < x0 + d.width; x++) {
                if (robot.getPixelColor(x, y).equals(Color.blue)) {
                    passed = true;
                    break;
                }
            }

            if (!passed) {
                throw new RuntimeException("Test failed.");
            }

        }
    });
}
 
Example 4
Source File: bug6824395.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
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!");
            }
        }
    });
}
 
Example 5
Source File: MouseComboBoxTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    robot = new Robot();
    robot.setAutoDelay(50);

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

    for (int i = 0; i < items.length; i++) {
        // Open popup
        robot.keyPress(KeyEvent.VK_DOWN);
        robot.keyRelease(KeyEvent.VK_DOWN);
        toolkit.realSync();

        Point point = getItemPointToClick(i);
        robot.mouseMove(point.x, point.y);
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
        toolkit.realSync();

        if (i != getSelectedIndex()) {
            throw new RuntimeException("Test Failed! Incorrect value of selected index = " + getSelectedIndex() +
                    ", expected value = " + i);
        }
    }
}
 
Example 6
Source File: bug4251579.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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 = htmlComponent.getLocationOnScreen();
            Dimension d = htmlComponent.getSize();
            int x0 = p.x;
            int y = p.y + d.height / 2;

            for (int x = x0; x < x0 + d.width; x++) {
                if (robot.getPixelColor(x, y).equals(Color.blue)) {
                    passed = true;
                    break;
                }
            }

            if (!passed) {
                throw new RuntimeException("Test failed.");
            }

        }
    });
}
 
Example 7
Source File: bug8007006.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void sleep(int ms) {
    SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
    tk.realSync();

    try {
        Thread.sleep(ms);
    } catch (Exception ignore) {
    }
}
 
Example 8
Source File: Test7194184.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
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");
            }
        }
    });
}
 
Example 9
Source File: EventWhenTest.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        Frame frame = new Frame();

        try {
            Button b = new Button("Button");
            frame.setBounds(300, 300, 300, 300);
            frame.add(b);
            frame.setVisible(true);
            toolkit.realSync();

            Robot robot = new Robot();
            robot.mouseMove((int)frame.getLocationOnScreen().getX() + 150,
                    (int)frame.getLocationOnScreen().getY() + 150);

            eventsCount = 0;
            System.out.println("Clicking mouse...");
            for (int i = 0; i < 300 && !failed; i++) {
                robot.mousePress(InputEvent.BUTTON1_MASK);
                robot.mouseRelease(InputEvent.BUTTON1_MASK);
                Thread.sleep(10);
                b.setLabel("Click: " + i);
            }

            if (eventsCount == 0) {
                throw new RuntimeException("No events were received");
            }

            if (failed) {
                throw new RuntimeException("Test failed.");
            }
            System.out.println("Clicking mouse done: " + eventsCount + " events.");

            b.requestFocusInWindow();
            toolkit.realSync();

            eventsCount = 0;
            System.out.println("Typing a key...");
            for (int i = 0; i < 300 && !failed; i++) {
                robot.keyPress(KeyEvent.VK_A);
                robot.keyRelease(KeyEvent.VK_A);
                Thread.sleep(10);
                b.setLabel("Type: " + i);
            }
            System.out.println("Key typing done: " + eventsCount + " events.");

            if (eventsCount == 0) {
                throw new RuntimeException("No events were received");
            }

            if (failed) {
                throw new RuntimeException("Test failed.");
            }

            System.out.println("Success!");
        } finally {
            frame.dispose();
        }
    }
 
Example 10
Source File: bug7049024.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        SwingUtilities.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                frame = new JFrame("Test");
                textField = new JTextField("test selection for textfield");
                button = new JButton("To compete the focus");

                frame.setLayout(new FlowLayout());
                frame.getContentPane().add(textField);
                frame.getContentPane().add(button);

                frame.pack();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setVisible(true);
            }
        });
        toolkit.realSync();

        clipboard = textField.getToolkit().getSystemSelection();
        if (null == clipboard) {
            return;
        }

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

        SwingUtilities.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                caret = (DefaultCaret) textField.getCaret();
                caret.setDot(2);
                caret.moveDot(4);
            }
        });
        toolkit.realSync();

        String oldSelection = (String) clipboard.getData(DataFlavor.stringFlavor);
        System.out.println("oldSelection is " + oldSelection);

        SwingUtilities.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                button.requestFocusInWindow();
            }
        });
        toolkit.realSync(); // So JTextField loses the focus.

        SwingUtilities.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                caret.setDot(4);
                caret.moveDot(6);
            }
        });
        toolkit.realSync();

        String newSelection = (String) clipboard.getData(DataFlavor.stringFlavor);
        System.out.println("newSelection is " + newSelection);

        boolean passed = newSelection.equals(oldSelection);

        SwingUtilities.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                frame.dispose();
            }
        });

        if (!passed) {
            throw new RuntimeException("The test for bug 7049024 failed");
        }
    }
 
Example 11
Source File: bug4530474.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
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());
                }
            }
        });

    }
 
Example 12
Source File: bug4330357.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    robot = new Robot();
    robot.setAutoDelay(50);

    UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");

    javax.swing.SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            createAndShowGUI();
        }
    });

    toolkit.realSync();

    clickMouse(getTreeRowClickPoint(1));
    Util.hitKeys(robot, KeyEvent.VK_F2);
    Util.hitKeys(robot, KeyEvent.VK_A, KeyEvent.VK_B, KeyEvent.VK_C);
    toolkit.realSync();

    if (!hasComponent(JTextField.class)) {
        throw new RuntimeException("Cell editor is missed for path: color");
    }


    clickMouse(getButtonClickPoint());
    toolkit.realSync();

    clickMouse(getTreeRowClickPoint(2));
    Util.hitKeys(robot, KeyEvent.VK_F2);
    toolkit.realSync();

    if (!hasComponent(JComboBox.class)) {
        throw new RuntimeException("Cell editor is missed for path: sports");
    }

    if (hasComponent(JTextField.class)) {
        throw new RuntimeException("Cell editor is wrongly shown for path: color");
    }
}
 
Example 13
Source File: bug4278839.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) {
    try {

        toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        robo = new Robot();
        robo.setAutoDelay(100);

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

        toolkit.realSync();

        clickMouse();
        toolkit.realSync();


        if ("Aqua".equals(UIManager.getLookAndFeel().getID())) {
            Util.hitKeys(robo, KeyEvent.VK_HOME);
        } else {
            Util.hitKeys(robo, KeyEvent.VK_CONTROL, KeyEvent.VK_HOME);
        }
        toolkit.realSync();

        passed &= moveCaret(true) == 1;
        passed &= moveCaret(true) == 5;
        passed &= moveCaret(true) == 8;
        passed &= moveCaret(true) == 9;
        passed &= moveCaret(true) == 13;
        passed &= moveCaret(true) == 16;
        passed &= moveCaret(true) == 17;
        passed &= moveCaret(false) == 16;
        passed &= moveCaret(false) == 13;
        passed &= moveCaret(false) == 9;
        passed &= moveCaret(false) == 8;
        passed &= moveCaret(false) == 5;
        passed &= moveCaret(false) == 1;
        passed &= moveCaret(false) == 0;

    } catch (Exception e) {
        throw new RuntimeException("Test failed because of an exception:",
                e);
    }

    if (!passed) {
        throw new RuntimeException("Test failed.");
    }
}
 
Example 14
Source File: bug7129742.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            frame = new JFrame("Test");
            TextArea textArea = new TextArea("Non-editable textArea");
            textArea.setEditable(false);
            frame.setLayout(new FlowLayout());
            frame.add(textArea);
            frame.pack();
            frame.setVisible(true);

            try {
                Class XTextAreaPeerClzz  = textArea.getPeer().getClass();
                System.out.println(XTextAreaPeerClzz.getName());
                if (!XTextAreaPeerClzz.getName().equals("sun.awt.X11.XTextAreaPeer")) {
                    fastreturn = true;
                    return;
                }

                Field jtextField = XTextAreaPeerClzz.getDeclaredField("jtext");
                jtextField.setAccessible(true);
                JTextArea jtext = (JTextArea)jtextField.get(textArea.getPeer());
                caret = (DefaultCaret) jtext.getCaret();

                textArea.requestFocusInWindow();
            } catch (NoSuchFieldException | SecurityException
                     | IllegalArgumentException | IllegalAccessException e) {
                /* These exceptions mean the implementation of XTextAreaPeer is
                 * changed, this testcase is not valid any more, fix it or remove.
                 */
                frame.dispose();
                throw new RuntimeException("This testcase is not valid any more!");
            }
        }
    });
    toolkit.realSync();

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            try{
                if (fastreturn) {
                    return;
                }
                boolean passed = caret.isActive();
                System.out.println("is caret visible : " + passed);

                if (!passed) {
                    throw new RuntimeException("The test for bug 71297422 failed");
                }
            } finally {
                frame.dispose();
            }
        }
    });
}
 
Example 15
Source File: WrongAltProcessing.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void sync() {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    toolkit.realSync();
}
 
Example 16
Source File: bug4908142.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        Robot robot = new Robot();
        robot.setAutoDelay(50);

        SwingUtilities.invokeAndWait(new Runnable() {

            public void run() {
                createAndShowGUI();
            }
        });

        toolkit.realSync();

        SwingUtilities.invokeAndWait(new Runnable() {

            public void run() {
                tree.requestFocus();
                tree.setSelectionRow(0);
            }
        });

        toolkit.realSync();


        robot.keyPress(KeyEvent.VK_A);
        robot.keyRelease(KeyEvent.VK_A);
        robot.keyPress(KeyEvent.VK_A);
        robot.keyRelease(KeyEvent.VK_A);
        robot.keyPress(KeyEvent.VK_D);
        robot.keyRelease(KeyEvent.VK_D);
        toolkit.realSync();


        String sel = Util.invokeOnEDT(new Callable<String>() {

            @Override
            public String call() throws Exception {
                return tree.getLastSelectedPathComponent().toString();
            }
        });

        if (!"aad".equals(sel)) {
            throw new Error("The selected index should be \"aad\", but not " + sel);
        }
    }
 
Example 17
Source File: bug4247996.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        Robot robot = new Robot();
        robot.setAutoDelay(50);

        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");

        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {

            public void run() {
                createAndShowGUI();
            }
        });

        toolkit.realSync();

        Point point = getButtonCenter();
        robot.mouseMove(point.x, point.y);
        toolkit.realSync();

        checkButtonsSize();

    }
 
Example 18
Source File: bug4247996.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        Robot robot = new Robot();
        robot.setAutoDelay(50);

        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");

        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {

            public void run() {
                createAndShowGUI();
            }
        });

        toolkit.realSync();

        Point point = getButtonCenter();
        robot.mouseMove(point.x, point.y);
        toolkit.realSync();

        checkButtonsSize();

    }
 
Example 19
Source File: bug4624207.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    Robot robot = new Robot();
    robot.setAutoDelay(50);

    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            createAndShowGUI();
        }
    });

    toolkit.realSync();

    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            txtField.requestFocus();
        }
    });

    toolkit.realSync();

    if (!focusGained) {
        throw new RuntimeException("Couldn't gain focus for text field");
    }

    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            tab.addChangeListener((ChangeListener) listener);
            txtField.removeFocusListener((FocusListener) listener);
        }
    });

    toolkit.realSync();

    if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
        Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_B);
    } else {
        Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_B);
    }

    toolkit.realSync();

    if (!stateChanged || tab.getSelectedIndex() != 1) {
        throw new RuntimeException("JTabbedPane mnemonics don't work from outside the tabbed pane");
    }
}
 
Example 20
Source File: bug6542335.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
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);
            }
        }
    });
}