java.awt.Dialog#isVisible ( )源码实例Demo

下面列出了java.awt.Dialog#isVisible ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

private static void clickOnDialog(Dialog dialog) {
    try {
        long time = System.currentTimeMillis() + 200;

        while (!dialog.isVisible()) {
            if (time < System.currentTimeMillis()) {
                throw new RuntimeException("Dialog is not visible!");
            }
            Thread.sleep(10);
        }

        Point point = getCenterPoint(dialog);
        Robot robot = new Robot();
        robot.setAutoDelay(50);

        robot.mouseMove(point.x, point.y);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);

    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
private static void clickOnDialog(Dialog dialog) {
    try {
        long time = System.currentTimeMillis() + 200;

        while (!dialog.isVisible()) {
            if (time < System.currentTimeMillis()) {
                throw new RuntimeException("Dialog is not visible!");
            }
            Thread.sleep(10);
        }

        Point point = getCenterPoint(dialog);
        Robot robot = new Robot();
        robot.setAutoDelay(50);

        robot.mouseMove(point.x, point.y);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);

    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
private static void clickOnDialog(Dialog dialog) {
    try {
        long time = System.currentTimeMillis() + 200;

        while (!dialog.isVisible()) {
            if (time < System.currentTimeMillis()) {
                throw new RuntimeException("Dialog is not visible!");
            }
            Thread.sleep(10);
        }

        Point point = getCenterPoint(dialog);
        Robot robot = new Robot();
        robot.setAutoDelay(50);

        robot.mouseMove(point.x, point.y);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);

    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
private static void clickOnDialog(Dialog dialog) {
    try {
        long time = System.currentTimeMillis() + 200;

        while (!dialog.isVisible()) {
            if (time < System.currentTimeMillis()) {
                throw new RuntimeException("Dialog is not visible!");
            }
            Thread.sleep(10);
        }

        Point point = getCenterPoint(dialog);
        Robot robot = new Robot();
        robot.setAutoDelay(50);

        robot.mouseMove(point.x, point.y);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);

    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
private static void clickOnDialog(Dialog dialog) {
    try {
        long time = System.currentTimeMillis() + 200;

        while (!dialog.isVisible()) {
            if (time < System.currentTimeMillis()) {
                throw new RuntimeException("Dialog is not visible!");
            }
            Thread.sleep(10);
        }
        Robot robot = new Robot();
        robot.setAutoDelay(50);
        robot.waitForIdle();
        robot.delay(200);

        Point point = getCenterPoint(dialog);

        robot.mouseMove(point.x, point.y);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);

    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
private static void clickOnDialog(Dialog dialog) {
    try {
        long time = System.currentTimeMillis() + 200;

        while (!dialog.isVisible()) {
            if (time < System.currentTimeMillis()) {
                throw new RuntimeException("Dialog is not visible!");
            }
            Thread.sleep(10);
        }

        Point point = getCenterPoint(dialog);
        Robot robot = new Robot();
        robot.setAutoDelay(50);

        robot.mouseMove(point.x, point.y);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);

    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
源代码7 项目: hottub   文件: MissingEventsOnModalDialogTest.java
private static void clickOnDialog(Dialog dialog) {
    try {
        long time = System.currentTimeMillis() + 200;

        while (!dialog.isVisible()) {
            if (time < System.currentTimeMillis()) {
                throw new RuntimeException("Dialog is not visible!");
            }
            Thread.sleep(10);
        }

        Point point = getCenterPoint(dialog);
        Robot robot = new Robot();
        robot.setAutoDelay(50);

        robot.mouseMove(point.x, point.y);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);

    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
源代码8 项目: dragonwell8_jdk   文件: ModalDialogOrderingTest.java
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);
    }
}
 
源代码9 项目: TencentKona-8   文件: ModalDialogOrderingTest.java
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);
    }
}
 
源代码10 项目: jdk8u60   文件: ModalDialogOrderingTest.java
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);
    }
}
 
源代码11 项目: openjdk-jdk8u   文件: ModalDialogOrderingTest.java
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);
    }
}
 
源代码12 项目: netbeans   文件: I18nTestWizardAction.java
/** 
 * We create non-modal but not rentrant dialog. Wait until
 * previous one is closed.
 */
protected boolean enable(Node[] activatedNodes) {

    if (Util.wizardEnabled(activatedNodes) == false) {
        return false;
    }
    
    Dialog previous = (Dialog) dialogWRef.get();
    if (previous == null) return true;
    return previous.isVisible() == false;
}
 
源代码13 项目: jdk8u-jdk   文件: ModalDialogOrderingTest.java
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);
    }
}
 
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);
    }
}
 
源代码15 项目: jdk8u-jdk   文件: ModalDialogOrderingTest.java
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);
    }
}
 
源代码16 项目: hottub   文件: ModalDialogOrderingTest.java
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);
    }
}
 
源代码17 项目: openjdk-8-source   文件: ModalDialogOrderingTest.java
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);
    }
}
 
源代码18 项目: openjdk-8   文件: ModalDialogOrderingTest.java
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);
    }
}
 
源代码19 项目: jdk8u_jdk   文件: ModalDialogOrderingTest.java
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);
    }
}
 
源代码20 项目: openjdk-jdk9   文件: ModalDialogOrderingTest.java
private static void runTest(Dialog dialog, Frame frame) {
    try {
        ExtendedRobot robot = new ExtendedRobot();
        robot.setAutoDelay(50);
        robot.mouseMove(300, 300);

        while (!dialog.isVisible()) {
            robot.waitForIdle(1000);
        }

        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);
        robot.waitForIdle(1000);

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

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


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