java.awt.Robot Java Examples

The following examples show how to use java.awt.Robot. 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: bug7097771.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final bug7097771 frame = new bug7097771();
    frame.setSize(300, 300);
    frame.setLocationRelativeTo(null);
    final Button button = new Button();
    button.addActionListener(frame);
    frame.add(button);
    frame.setVisible(true);
    sleep();
    frame.setEnabled(false);
    button.setEnabled(false);
    button.setEnabled(true);
    sleep();
    Util.clickOnComp(button, new Robot());
    sleep();
    frame.dispose();
    if (action) {
        throw new RuntimeException("Button is not disabled.");
    }
}
 
Example #2
Source File: Guide.java    From SikuliX1 with MIT License 6 votes vote down vote up
private void init(Region region) {
  try {
    robot = new Robot();
  } catch (AWTException e1) {
    e1.printStackTrace();
  }
  content = getJPanel();
  _region = region;
  Rectangle rect = _region.getRect();
  content.setPreferredSize(rect.getSize());
  add(content);
  setBounds(rect);
  getRootPane().putClientProperty("Window.shadow", Boolean.FALSE);
  ((JPanel) getContentPane()).setDoubleBuffered(true);
  setVisible(false);
  setFocusableWindowState(false);
}
 
Example #3
Source File: bug7055065.java    From jdk8u-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();
    Robot robot = new Robot();

    SwingUtilities.invokeAndWait(new Runnable() {

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

    toolkit.realSync();
    clickCell(robot, 1, 1);
    Util.hitKeys(robot, KeyEvent.VK_BACK_SPACE, KeyEvent.VK_BACK_SPACE,
            KeyEvent.VK_BACK_SPACE);

    toolkit.realSync();
    clickColumnHeader(robot, 1);

    toolkit.realSync();
    clickColumnHeader(robot, 1);
}
 
Example #4
Source File: bug6505523.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();
    Robot robot = new Robot();
    robot.setAutoDelay(50);

    SwingUtilities.invokeAndWait(new Runnable() {

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

    toolkit.realSync();

    Point point = getRowPointToClick(2);
    robot.mouseMove(point.x, point.y);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);

    toolkit.realSync();

}
 
Example #5
Source File: bug4524490.java    From TencentKona-8 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();
    Robot robot = new Robot();
    robot.setAutoDelay(50);

    UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");

    SwingUtilities.invokeLater(new Runnable() {

        public void run() {
            fileChooser = new JFileChooser();
            fileChooser.showOpenDialog(null);
        }
    });

    toolkit.realSync();

    if (OSInfo.OSType.MACOSX.equals(OSInfo.getOSType())) {
        Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_L);
    } else {
        Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_L);
    }
    checkFocus();
}
 
Example #6
Source File: DisposeFrameOnDragTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Throwable {

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

        Util.waitForIdle(null);
        try {
            Point loc = textArea.getLocationOnScreen();
            Util.drag(new Robot(),
                    new Point((int) loc.x + 3, (int) loc.y + 3),
                    new Point((int) loc.x + 40, (int) loc.y + 40),
                    InputEvent.BUTTON1_MASK);
        } catch (AWTException ex) {
            throw new RuntimeException("Could not initiate a drag operation");
        }
        Util.waitForIdle(null);
    }
 
Example #7
Source File: deadKeyMacOSX.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
            return;
        }

        Robot robot = new Robot();
        robot.setAutoDelay(50);

        createAndShowGUI();

        // Pressed keys: Alt + E + A
        // Results:  ALT + VK_DEAD_ACUTE + a with accute accent
        keyPress(robot, KeyEvent.VK_ALT);
        keyPress(robot, KeyEvent.VK_E);
        keyRelease(robot, KeyEvent.VK_E);
        keyRelease(robot, KeyEvent.VK_ALT);

        keyPress(robot, KeyEvent.VK_A);
        keyRelease(robot, KeyEvent.VK_A);

        if (state != 3) {
            throw new RuntimeException("Wrong number of key events.");
        }
    }
 
Example #8
Source File: ScrollPaneValidateTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws AWTException {
  Robot robot = new Robot();
  final ScrollPaneValidateTest obj = new ScrollPaneValidateTest();
  obj.setVisible(true);

  // set to some scroll position
  obj.pane.setScrollPosition(600, 200);

  // get the newly set position
  Point scrollPosition = obj.pane.getScrollPosition();

  // call validate multiple times
  obj.pane.validate();
  robot.delay(1000);
  obj.pane.validate();
  robot.delay(1000);

  // compare position after calling the validate function
  if(!scrollPosition.equals(obj.pane.getScrollPosition())) {
    obj.dispose();
    throw new RuntimeException("Scrolling position is changed in ScrollPane");
  }

  obj.dispose();
  return;
}
 
Example #9
Source File: RemovedComponentMouseListener.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    SwingUtilities.invokeAndWait(() -> {
        new RemovedComponentMouseListener();
    });

    Robot r = Util.createRobot();
    r.setAutoDelay(100);
    r.waitForIdle();
    Util.pointOnComp(button, r);

    r.waitForIdle();
    r.mousePress(InputEvent.BUTTON1_MASK);
    r.waitForIdle();
    r.mouseRelease(InputEvent.BUTTON1_MASK);
    r.waitForIdle();
    if (!mouseReleasedReceived) {
        throw new RuntimeException("mouseReleased event was not received");
    }
}
 
Example #10
Source File: MissingEventsOnModalDialogTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void mouseDND(Robot robot, int x1, int y1, int x2, int y2) {

        int N = 20;
        int x = x1;
        int y = y1;
        int dx = (x2 - x1) / N;
        int dy = (y2 - y1) / N;

        robot.mousePress(InputEvent.BUTTON1_MASK);

        for (int i = 0; i < N; i++) {
            robot.mouseMove(x += dx, y += dy);
        }

        robot.mouseRelease(InputEvent.BUTTON1_MASK);
    }
 
Example #11
Source File: ScrollPaneValidateTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws AWTException {
  Robot robot = new Robot();
  final ScrollPaneValidateTest obj = new ScrollPaneValidateTest();
  obj.setVisible(true);

  // set to some scroll position
  obj.pane.setScrollPosition(600, 200);

  // get the newly set position
  Point scrollPosition = obj.pane.getScrollPosition();

  // call validate multiple times
  obj.pane.validate();
  robot.delay(1000);
  obj.pane.validate();
  robot.delay(1000);

  // compare position after calling the validate function
  if(!scrollPosition.equals(obj.pane.getScrollPosition())) {
    obj.dispose();
    throw new RuntimeException("Scrolling position is changed in ScrollPane");
  }

  obj.dispose();
  return;
}
 
Example #12
Source File: ImageDecoratedDnDNegative.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void moveTo(
    Robot r,
    Point b,
    Point e)
{
    Point2D.Double ee = new Point2D.Double(e.getX(), e.getY());
    Point2D.Double bb = new Point2D.Double(b.getX(), b.getY());
    final int count = (int)(ee.distance(bb));
    Point2D.Double c = new Point2D.Double(bb.getX(), bb.getY());
    for(int i=0; i<count; ++i){
        c.setLocation(
                bb.getX() + (ee.getX()-bb.getX())*i/count,
                bb.getY() + (ee.getY()-bb.getY())*i/count);
        r.mouseMove(
                (int)c.getX(),
                (int)c.getY());
        r.delay(5);
    }
    r.mouseMove(
            (int)ee.getX(),
            (int)ee.getY());
    r.delay(5);
}
 
Example #13
Source File: KeyCharTest.java    From dragonwell8_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();

        Frame frame = new Frame();
        frame.setSize(300, 300);
        frame.setVisible(true);
        toolkit.realSync();

        Robot robot = new Robot();

        robot.keyPress(KeyEvent.VK_DELETE);
        robot.keyRelease(KeyEvent.VK_DELETE);
        toolkit.realSync();

        frame.dispose();

        if (eventsCount != 3) {
            throw new RuntimeException("Wrong number of key events: " + eventsCount);
        }
    }
 
Example #14
Source File: MenuItemIconTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    robot = new Robot();
    String name = UIManager.getSystemLookAndFeelClassName();
    try {
        UIManager.setLookAndFeel(name);
    } catch (ClassNotFoundException | InstantiationException |
            IllegalAccessException | UnsupportedLookAndFeelException e) {
        throw new RuntimeException("Test Failed");
    }
    createUI();
    robot.waitForIdle();
    executeTest();
    if (!"".equals(errorMessage)) {
        throw new RuntimeException(errorMessage);
    }
}
 
Example #15
Source File: ImageTransmitter.java    From Smack with Apache License 2.0 6 votes vote down vote up
public ImageTransmitter(DatagramSocket socket, InetAddress remoteHost, int remotePort, Rectangle area) {

        try {
            robot = new Robot();

            maxI = (int) Math.ceil(area.getWidth() / tileWidth);
            maxJ = (int) Math.ceil(area.getHeight() / tileWidth);

            tiles = new int[maxI][maxJ][tileWidth * tileWidth];

            this.area = area;
            this.socket = socket;
            localHost = socket.getLocalAddress();
            localPort = socket.getLocalPort();
            this.remoteHost = remoteHost;
            this.remotePort = remotePort;
            this.encoder = new DefaultEncoder();

            transmit = true;

        }
        catch (AWTException e) {
            LOGGER.log(Level.WARNING, "exception", e);
        }

    }
 
Example #16
Source File: RemovedComponentMouseListener.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    SwingUtilities.invokeAndWait(() -> {
        new RemovedComponentMouseListener();
    });

    Robot r = Util.createRobot();
    r.setAutoDelay(100);
    r.waitForIdle();
    Util.pointOnComp(button, r);

    r.waitForIdle();
    r.mousePress(InputEvent.BUTTON1_MASK);
    r.waitForIdle();
    r.mouseRelease(InputEvent.BUTTON1_MASK);
    r.waitForIdle();
    if (!mouseReleasedReceived) {
        throw new RuntimeException("mouseReleased event was not received");
    }
}
 
Example #17
Source File: BackgroundIsNotUpdated.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(final String[] args) throws AWTException {
    final Window window = new BackgroundIsNotUpdated(null);
    window.setSize(300, 300);
    window.setLocationRelativeTo(null);
    window.setVisible(true);
    sleep();
    window.setBackground(Color.GREEN);
    sleep();
    final Robot robot = new Robot();
    robot.setAutoDelay(200);
    Point point = window.getLocationOnScreen();
    Color color = robot.getPixelColor(point.x + window.getWidth() / 2,
                                      point.y + window.getHeight() / 2);
    window.dispose();
    if (!color.equals(Color.GREEN)) {
        throw new RuntimeException(
                "Expected: " + Color.GREEN + " , Actual: " + color);
    }
}
 
Example #18
Source File: DeadKeySystemAssertionDialog.java    From openjdk-8 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();
        Frame frame = new Frame();
        frame.setSize(300, 200);

        TextField textField = new TextField();
        frame.add(textField);

        frame.setVisible(true);
        toolkit.realSync();

        textField.requestFocus();
        toolkit.realSync();

        // Check that the system assertion dialog does not block Java
        Robot robot = new Robot();
        robot.setAutoDelay(50);
        robot.keyPress(KeyEvent.VK_A);
        robot.keyRelease(KeyEvent.VK_A);
        toolkit.realSync();

        frame.setVisible(false);
        frame.dispose();
    }
 
Example #19
Source File: RemovedComponentMouseListener.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 {
    SwingUtilities.invokeAndWait(() -> {
        new RemovedComponentMouseListener();
    });

    Robot r = Util.createRobot();
    r.setAutoDelay(100);
    r.waitForIdle();
    Util.pointOnComp(button, r);

    r.waitForIdle();
    r.mousePress(InputEvent.BUTTON1_MASK);
    r.waitForIdle();
    r.mouseRelease(InputEvent.BUTTON1_MASK);
    r.waitForIdle();
    if (!mouseReleasedReceived) {
        throw new RuntimeException("mouseReleased event was not received");
    }
}
 
Example #20
Source File: InternetExplorerDriverTest.java    From selenium with Apache License 2.0 5 votes vote down vote up
@NoDriverBeforeTest
@NoDriverAfterTest
@NeedsLocalEnvironment
@Test
public void testPersistentHoverCanBeTurnedOff() throws Exception {
  createNewDriver(new ImmutableCapabilities(ENABLE_PERSISTENT_HOVERING, false));

  driver.get(pages.javascriptPage);
  // Move to a different element to make sure the mouse is not over the
  // element with id 'item1' (from a previous test).
  new Actions(driver).moveToElement(driver.findElement(By.id("keyUp"))).build().perform();
  WebElement element = driver.findElement(By.id("menu1"));

  final WebElement item = driver.findElement(By.id("item1"));
  assertThat(item.getText()).isEqualTo("");

  ((JavascriptExecutor) driver).executeScript("arguments[0].style.background = 'green'", element);
  new Actions(driver).moveToElement(element).build().perform();

  // Move the mouse somewhere - to make sure that the thread firing the events making
  // hover persistent is not active.
  Robot robot = new Robot();
  robot.mouseMove(50, 50);

  // Intentionally wait to make sure hover DOES NOT persist.
  Thread.sleep(1000);

  wait.until(elementTextToEqual(item, ""));

  assertThat(item.getText()).isEqualTo("");
}
 
Example #21
Source File: bug8021253.java    From openjdk-jdk8u 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);

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

        toolkit.realSync();

        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                fileChooser.setSelectedFile(file);
            }
        });

        toolkit.realSync();

        robot.keyPress(KeyEvent.VK_ENTER);
        robot.keyRelease(KeyEvent.VK_ENTER);
        toolkit.realSync();

        if (!defaultKeyPressed) {
            throw new RuntimeException("Default button is not pressed");
        }
    }
 
Example #22
Source File: MultiResolutionSplashTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void testSplash(ImageInfo test) throws Exception {
    SplashScreen splashScreen = SplashScreen.getSplashScreen();

    if (splashScreen == null) {
        throw new RuntimeException("Splash screen is not shown!");
    }

    Graphics2D g = splashScreen.createGraphics();
    Rectangle splashBounds = splashScreen.getBounds();
    int screenX = (int) splashBounds.getCenterX();
    int screenY = (int) splashBounds.getCenterY();

    if(splashBounds.width != IMAGE_WIDTH){
        throw new RuntimeException(
                "SplashScreen#getBounds has wrong width");
    }
    if(splashBounds.height != IMAGE_HEIGHT){
        throw new RuntimeException(
                "SplashScreen#getBounds has wrong height");
    }

    Robot robot = new Robot();
    Color splashScreenColor = robot.getPixelColor(screenX, screenY);

    float scaleFactor = getScaleFactor();
    Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x;

    if (!compare(testColor, splashScreenColor)) {
        throw new RuntimeException(
                "Image with wrong resolution is used for splash screen!");
    }
}
 
Example #23
Source File: MissingCharsKorean.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void performTasks(Robot robotForKeyInput) {
    int taskCount = 0;

    lblTestStatus.setText("Running Tests..");
    robotForKeyInput.setAutoDelay(500);

    while (setKeyInput(taskCount)) {
        textFieldMain.setText("");
        textFieldMain.requestFocusInWindow();
        enterInput(robotForKeyInput, inKeyCodes);
        taskCount++;

        try {
            SwingUtilities.invokeAndWait(() -> {
                validateInput();
            });
        } catch (Exception e) {
            System.err.print("validateInput Failed : " + e.getMessage());
            testPassed = false;
            break;
        }

        if (!testPassed) {
            break;
        }
        setTaskStatus(false, taskCount);
    }
    setTaskStatus(true, taskCount);
}
 
Example #24
Source File: bug8021253.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);

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

        toolkit.realSync();

        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                fileChooser.setSelectedFile(file);
            }
        });

        toolkit.realSync();

        robot.keyPress(KeyEvent.VK_ENTER);
        robot.keyRelease(KeyEvent.VK_ENTER);
        toolkit.realSync();

        if (!defaultKeyPressed) {
            throw new RuntimeException("Default button is not pressed");
        }
    }
 
Example #25
Source File: MutterMaximizeTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void dragWindow(Window w, int dx, int dy, Robot robot) {
    Point p = Util.getTitlePoint(w);
    rmove(robot, p);
    rdown(robot);
    p.translate(dx, dy);
    rmove(robot, p);
    rup(robot);
}
 
Example #26
Source File: TestsWithFiles.java    From difido-reports with Apache License 2.0 5 votes vote down vote up
@Test(description = "Adding screenshot to the report")
public void testAddScreenshot0() throws IOException, AWTException {
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	Rectangle screenRectangle = new Rectangle(screenSize);
	Robot robot = new Robot();
	BufferedImage image = robot.createScreenCapture(screenRectangle);
	File imgFile = File.createTempFile("screenshot_file", "png");
	ImageIO.write(image, "png", imgFile);
	report.addImage(imgFile, "My screenshot file");
	imgFile.delete();

}
 
Example #27
Source File: SelectionAutoscrollTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
void waitUntilScrollIsPerformed(Robot robot) {
    try {
        Thread.sleep( SCROLL_DELAY );
    }
    catch( Exception e ) {
        throw new RuntimeException( e );
    }
}
 
Example #28
Source File: MouseWheelAbsXY.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void test(GraphicsConfiguration gc) throws AWTException {
    final Window frame = new Frame(gc);
    try {
        frame.addMouseWheelListener(e -> {
            wheelX = e.getXOnScreen();
            wheelY = e.getYOnScreen();
            done = true;
        });
        frame.setSize(300, 300);
        frame.setVisible(true);

        final Robot robot = new Robot();
        robot.setAutoDelay(50);
        robot.setAutoWaitForIdle(true);
        mouseX = frame.getX() + frame.getWidth() / 2;
        mouseY = frame.getY() + frame.getHeight() / 2;

        robot.mouseMove(mouseX, mouseY);
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseWheel(10);

        validate();
    } finally {
        frame.dispose();
    }
}
 
Example #29
Source File: MissingDragExitEventTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(final String[] args) throws Exception {
    try {
        final Robot r = new Robot();
        r.setAutoDelay(50);
        r.mouseMove(100, 100);
        Util.waitForIdle(r);

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

        final Point inside = new Point(frame.getLocationOnScreen());
        inside.translate(20, SIZE / 2);
        final Point outer = new Point(inside);
        outer.translate(-40, 0);
        r.mouseMove(inside.x, inside.y);
        r.mousePress(InputEvent.BUTTON1_MASK);
        try {
            for (int i = 0; i < 3; ++i) {
                Util.mouseMove(r, inside, outer);
                Util.mouseMove(r, outer, inside);
            }
        } finally {
            r.mouseRelease(InputEvent.BUTTON1_MASK);
        }
        sleep(r);

        if (FAILED || !MOUSE_ENTERED || !MOUSE_ENTERED_DT || !MOUSE_EXIT
                || !MOUSE_EXIT_TD) {
            throw new RuntimeException("Failed");
        }
    } finally {
        if (frame != null) {
            frame.dispose();
        }
    }
}
 
Example #30
Source File: ModalDialogOrderingTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void runTest(Dialog dialog, Frame frame) {
    try {
        Robot robot = new Robot();
        robot.setAutoDelay(50);
        robot.mouseMove(300, 300);

        while (!dialog.isVisible()) {
            sleep();
        }

        Rectangle dialogBounds = dialog.getBounds();
        Rectangle frameBounds = frame.getBounds();

        int y1 = dialogBounds.y + dialogBounds.height;
        int y2 = frameBounds.y + frameBounds.height;

        int clickX = frameBounds.x + frameBounds.width / 2;
        int clickY = y1 + (y2 - y1) / 2;

        robot.mouseMove(clickX, clickY);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        sleep();

        int colorX = dialogBounds.x + dialogBounds.width / 2;
        int colorY = dialogBounds.y + dialogBounds.height / 2;

        Color color = robot.getPixelColor(colorX, colorY);

        dialog.dispose();
        frame.dispose();

        if (!DIALOG_COLOR.equals(color)) {
            throw new RuntimeException("The frame is on top"
                    + " of the modal dialog!");
        }
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}