当前位置: 首页>>代码示例>>Java>>正文


Java Robot.setAutoWaitForIdle方法代码示例

本文整理汇总了Java中java.awt.Robot.setAutoWaitForIdle方法的典型用法代码示例。如果您正苦于以下问题:Java Robot.setAutoWaitForIdle方法的具体用法?Java Robot.setAutoWaitForIdle怎么用?Java Robot.setAutoWaitForIdle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Robot的用法示例。


在下文中一共展示了Robot.setAutoWaitForIdle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import java.awt.Robot; //导入方法依赖的package包/类
public static void main(final String[] args) throws Exception {
    robot = new Robot();
    robot.setAutoDelay(100);
    robot.setAutoWaitForIdle(true);
    GraphicsEnvironment ge =
            GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] sds = ge.getScreenDevices();
    UIManager.LookAndFeelInfo[] lookAndFeelArray =
            UIManager.getInstalledLookAndFeels();
    for (UIManager.LookAndFeelInfo lookAndFeelItem : lookAndFeelArray) {
        System.setProperty(PROPERTY_NAME, "true");
        step(sds, lookAndFeelItem);
        if (lookAndFeelItem.getClassName().contains("Aqua")) {
            System.setProperty(PROPERTY_NAME, "false");
            step(sds, lookAndFeelItem);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:JComboBoxPopupLocation.java

示例2: main

import java.awt.Robot; //导入方法依赖的package包/类
public static void main(final String[] args) throws AWTException {
    final boolean dump = Boolean.parseBoolean(args[0]);
    final Window w = new Frame() {
        @Override
        public void list(final PrintStream out, final int indent) {
            super.list(out, indent);
            dumped = true;
        }
    };
    w.setSize(200, 200);
    w.setLocationRelativeTo(null);
    w.setVisible(true);

    final Robot robot = new Robot();
    robot.setAutoDelay(50);
    robot.setAutoWaitForIdle(true);
    robot.mouseMove(w.getX() + w.getWidth() / 2,
                    w.getY() + w.getHeight() / 2);
    robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);

    robot.keyPress(KeyEvent.VK_CONTROL);
    robot.keyPress(KeyEvent.VK_SHIFT);
    robot.keyPress(KeyEvent.VK_F1);
    robot.keyRelease(KeyEvent.VK_F1);
    robot.keyRelease(KeyEvent.VK_SHIFT);
    robot.keyRelease(KeyEvent.VK_CONTROL);

    w.dispose();
    if (dumped != dump) {
        throw new RuntimeException("Exp:" + dump + ", actual:" + dumped);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:DumpOnKey.java

示例3: test

import java.awt.Robot; //导入方法依赖的package包/类
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();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:MouseWheelAbsXY.java

示例4: checkAltRightClickEvent

import java.awt.Robot; //导入方法依赖的package包/类
private void checkAltRightClickEvent(int eventToCheck) throws InterruptedException, InvocationTargetException, AWTException {
    events = eventToCheck;
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            actionsArea.setText("");
        }
    });
    driver = new JavaDriver();
    WebElement b = driver.findElement(By.name("click-me"));
    WebElement t = driver.findElement(By.name("actions"));

    Point location = EventQueueWait.call_noexc(button, "getLocationOnScreen");
    Dimension size = EventQueueWait.call_noexc(button, "getSize");
    Robot r = new Robot();
    r.setAutoDelay(10);
    r.setAutoWaitForIdle(true);
    r.keyPress(KeyEvent.VK_ALT);
    r.mouseMove(location.x + size.width / 2, location.y + size.height / 2);
    r.mousePress(InputEvent.BUTTON3_MASK);
    r.mouseRelease(InputEvent.BUTTON3_MASK);
    r.keyRelease(KeyEvent.VK_ALT);
    new EventQueueWait() {
        @Override public boolean till() {
            return actionsArea.getText().length() > 0;
        }
    }.wait("Waiting for actionsArea failed?");
    String expected = t.getText();
    tclear();
    Point location2 = EventQueueWait.call_noexc(actionsArea, "getLocationOnScreen");
    Dimension size2 = EventQueueWait.call_noexc(button, "getSize");
    r.mouseMove(location2.x + size2.width / 2, location2.y + size2.height / 2);
    r.mousePress(InputEvent.BUTTON1_MASK);
    r.mouseRelease(InputEvent.BUTTON1_MASK);

    new Actions(driver).moveToElement(b).keyDown(Keys.ALT).contextClick().keyUp(Keys.ALT).perform();
    AssertJUnit.assertEquals(expected, t.getText());
    // Wait till the previous click is processed by the EDT
    Thread.sleep(500);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:40,代码来源:NativeEventsTest.java

示例5: singleClickGeneratesSameEvents

import java.awt.Robot; //导入方法依赖的package包/类
public void singleClickGeneratesSameEvents() throws Throwable {
    events = MouseEvent.MOUSE_CLICKED;
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            actionsArea.setText("");
        }
    });
    driver = new JavaDriver();
    WebElement b = driver.findElement(By.name("click-me"));
    WebElement t = driver.findElement(By.name("actions"));

    Point location = EventQueueWait.call_noexc(button, "getLocationOnScreen");
    Dimension size = EventQueueWait.call_noexc(button, "getSize");
    Robot r = new Robot();
    r.setAutoDelay(10);
    r.setAutoWaitForIdle(true);
    r.mouseMove(location.x + size.width / 2, location.y + size.height / 2);
    r.mousePress(InputEvent.BUTTON1_MASK);
    r.mouseRelease(InputEvent.BUTTON1_MASK);
    new EventQueueWait() {
        @Override public boolean till() {
            return actionsArea.getText().length() > 0;
        }
    }.wait("Waiting for actionsArea failed?");
    String expected = t.getText();
    tclear();
    Point location2 = EventQueueWait.call_noexc(actionsArea, "getLocationOnScreen");
    Dimension size2 = EventQueueWait.call_noexc(actionsArea, "getSize");
    r.mouseMove(location2.x + size2.width / 2, location2.y + size2.height / 2);
    r.mousePress(InputEvent.BUTTON1_MASK);
    r.mouseRelease(InputEvent.BUTTON1_MASK);

    b.click();
    AssertJUnit.assertEquals(expected, t.getText());

    tclear();
    new Actions(driver).moveToElement(b).click().perform();
    AssertJUnit.assertEquals(expected, t.getText());

}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:41,代码来源:NativeEventsTest.java

示例6: draggedGeneratesSameEvents

import java.awt.Robot; //导入方法依赖的package包/类
public void draggedGeneratesSameEvents() throws Throwable {
    events = MouseEvent.MOUSE_DRAGGED;
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            actionsArea.setText("");
        }
    });
    driver = new JavaDriver();
    WebElement b = driver.findElement(By.name("click-me"));
    WebElement t = driver.findElement(By.name("actions"));

    Point location = EventQueueWait.call_noexc(button, "getLocationOnScreen");
    Dimension size = EventQueueWait.call_noexc(button, "getSize");
    Robot r = new Robot();
    r.setAutoDelay(10);
    r.setAutoWaitForIdle(true);
    Point location2 = EventQueueWait.call_noexc(actionsArea, "getLocationOnScreen");
    Dimension size2 = EventQueueWait.call_noexc(actionsArea, "getSize");

    r.mouseMove(location.x + size.width / 2, location.y + size.height / 2);
    r.mousePress(InputEvent.BUTTON1_MASK);
    r.mouseMove(location2.x + size2.width / 2, location2.y + size2.height / 2);
    r.mouseRelease(InputEvent.BUTTON1_MASK);
    new EventQueueWait() {
        @Override public boolean till() {
            return actionsArea.getText().length() > 0;
        }
    }.wait("Waiting for actionsArea failed?");
    String expected = t.getText();
    tclear();
    r.mousePress(InputEvent.BUTTON1_MASK);
    r.mouseRelease(InputEvent.BUTTON1_MASK);

    b.click();
    tclear();
    System.err.println("============================");
    new Actions(driver).clickAndHold(b).moveToElement(b).release().perform();
    System.err.println("============================");
    AssertJUnit.assertEquals(expected, t.getText());
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:41,代码来源:NativeEventsTest.java

示例7: checkDoubleClickEvent

import java.awt.Robot; //导入方法依赖的package包/类
private void checkDoubleClickEvent(int eventToCheck) throws InterruptedException, InvocationTargetException, AWTException {
    events = eventToCheck;
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            actionsArea.setText("");
        }
    });
    driver = new JavaDriver();
    WebElement b = driver.findElement(By.name("click-me"));
    WebElement t = driver.findElement(By.name("actions"));

    Point location = EventQueueWait.call_noexc(button, "getLocationOnScreen");
    Dimension size = EventQueueWait.call_noexc(button, "getSize");
    Robot r = new Robot();
    r.setAutoDelay(10);
    r.setAutoWaitForIdle(true);
    r.mouseMove(location.x + size.width / 2, location.y + size.height / 2);
    r.mousePress(InputEvent.BUTTON1_MASK);
    r.mouseRelease(InputEvent.BUTTON1_MASK);
    Thread.sleep(50);
    r.mousePress(InputEvent.BUTTON1_MASK);
    r.mouseRelease(InputEvent.BUTTON1_MASK);
    new EventQueueWait() {
        @Override public boolean till() {
            return actionsArea.getText().contains("(2");
        }
    }.wait("Waiting for actionsArea failed?");
    String expected = t.getText();
    tclear();
    Point location2 = EventQueueWait.call_noexc(actionsArea, "getLocationOnScreen");
    Dimension size2 = EventQueueWait.call_noexc(button, "getSize");
    r.mouseMove(location2.x + size2.width / 2, location2.y + size2.height / 2);
    r.mousePress(InputEvent.BUTTON1_MASK);
    r.mouseRelease(InputEvent.BUTTON1_MASK);

    new Actions(driver).moveToElement(b).doubleClick().perform();
    AssertJUnit.assertEquals(expected, t.getText());
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:39,代码来源:NativeEventsTest.java

示例8: enteredGeneratesSameEvents

import java.awt.Robot; //导入方法依赖的package包/类
public void enteredGeneratesSameEvents() throws Throwable {
    events = MouseEvent.MOUSE_ENTERED;
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            actionsArea.setText("");
        }
    });
    driver = new JavaDriver();
    WebElement b = driver.findElement(By.name("click-me"));
    WebElement t = driver.findElement(By.name("actions"));

    Point location = EventQueueWait.call_noexc(button, "getLocationOnScreen");
    Dimension size = EventQueueWait.call_noexc(button, "getSize");
    Robot r = new Robot();
    r.setAutoDelay(10);
    r.setAutoWaitForIdle(true);
    r.keyPress(KeyEvent.VK_ALT);
    r.mouseMove(location.x + size.width / 2, location.y + size.height / 2);
    r.mousePress(InputEvent.BUTTON1_MASK);
    r.mouseRelease(InputEvent.BUTTON1_MASK);
    r.keyRelease(KeyEvent.VK_ALT);
    new EventQueueWait() {
        @Override public boolean till() {
            return actionsArea.getText().length() > 0;
        }
    }.wait("Waiting for actionsArea failed?");
    String expected = t.getText();
    tclear();
    Point location2 = EventQueueWait.call_noexc(actionsArea, "getLocationOnScreen");
    Dimension size2 = EventQueueWait.call_noexc(actionsArea, "getSize");
    r.mouseMove(location2.x + size2.width / 2, location2.y + size2.height / 2);
    r.mousePress(InputEvent.BUTTON1_MASK);
    r.mouseRelease(InputEvent.BUTTON1_MASK);

    new Actions(driver).moveToElement(t).keyDown(Keys.ALT).moveToElement(b).click().keyUp(Keys.ALT).perform();
    AssertJUnit.assertEquals(expected, t.getText());

}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:39,代码来源:NativeEventsTest.java

示例9: main

import java.awt.Robot; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    robot = new Robot();
    robot.setAutoWaitForIdle(true);
    createUI();
    accessRecentSwatch();
    runRobot();
    testColorChooser();
    cleanUpUI();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:Test7194184.java

示例10: pressGeneratesSameEvents

import java.awt.Robot; //导入方法依赖的package包/类
public void pressGeneratesSameEvents() throws Throwable {
    events = MouseEvent.MOUSE_PRESSED;
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            actionsArea.setText("");
        }
    });
    driver = new JavaDriver();
    WebElement b = driver.findElement(By.name("click-me"));
    WebElement t = driver.findElement(By.name("actions"));

    Point location = EventQueueWait.call_noexc(button, "getLocationOnScreen");
    Dimension size = EventQueueWait.call_noexc(button, "getSize");
    Robot r = new Robot();
    r.setAutoDelay(10);
    r.setAutoWaitForIdle(true);
    r.mouseMove(location.x + size.width / 2, location.y + size.height / 2);
    r.mousePress(InputEvent.BUTTON1_MASK);
    r.mouseRelease(InputEvent.BUTTON1_MASK);
    new EventQueueWait() {
        @Override public boolean till() {
            return actionsArea.getText().length() > 0;
        }
    }.wait("Waiting for actionsArea failed?");
    String expected = t.getText();
    tclear();
    Point location2 = EventQueueWait.call_noexc(actionsArea, "getLocationOnScreen");
    Dimension size2 = EventQueueWait.call_noexc(actionsArea, "getSize");
    r.mouseMove(location2.x + size2.width / 2, location2.y + size2.height / 2);
    r.mousePress(InputEvent.BUTTON1_MASK);
    r.mouseRelease(InputEvent.BUTTON1_MASK);

    b.click();
    AssertJUnit.assertEquals(expected, t.getText());

    tclear();
    new Actions(driver).moveToElement(b).click().perform();
    AssertJUnit.assertEquals(expected, t.getText());

}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:41,代码来源:NativeEventsTest.java

示例11: releaseGeneratesSameEvents

import java.awt.Robot; //导入方法依赖的package包/类
public void releaseGeneratesSameEvents() throws Throwable {
    events = MouseEvent.MOUSE_RELEASED;
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            actionsArea.setText("");
        }
    });
    driver = new JavaDriver();
    WebElement b = driver.findElement(By.name("click-me"));
    WebElement t = driver.findElement(By.name("actions"));

    Point location = EventQueueWait.call_noexc(button, "getLocationOnScreen");
    Dimension size = EventQueueWait.call_noexc(button, "getSize");
    Robot r = new Robot();
    r.setAutoDelay(10);
    r.setAutoWaitForIdle(true);
    r.mouseMove(location.x + size.width / 2, location.y + size.height / 2);
    r.mousePress(InputEvent.BUTTON1_MASK);
    r.mouseRelease(InputEvent.BUTTON1_MASK);
    new EventQueueWait() {
        @Override public boolean till() {
            return actionsArea.getText().length() > 0;
        }
    }.wait("Waiting for actionsArea failed?");
    String expected = t.getText();
    tclear();
    Point location2 = EventQueueWait.call_noexc(actionsArea, "getLocationOnScreen");
    Dimension size2 = EventQueueWait.call_noexc(actionsArea, "getSize");
    r.mouseMove(location2.x + size2.width / 2, location2.y + size2.height / 2);
    r.mousePress(InputEvent.BUTTON1_MASK);
    r.mouseRelease(InputEvent.BUTTON1_MASK);

    b.click();
    AssertJUnit.assertEquals(expected, t.getText());

    tclear();
    new Actions(driver).moveToElement(b).click().perform();
    AssertJUnit.assertEquals(expected, t.getText());

}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:41,代码来源:NativeEventsTest.java

示例12: main

import java.awt.Robot; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    robot = new Robot();
    robot.setAutoDelay(200);
    robot.setAutoWaitForIdle(true);
    createUIWithSeperateMenuBar();
    shortcutTestCase();
    cleanUp();
    createUIWithIntegratedMenuBar();
    menuTestCase();
    cleanUp();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:ScreenMenuBarInputTwice.java

示例13: main

import java.awt.Robot; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    GraphicsDevice[] sds = GraphicsEnvironment.getLocalGraphicsEnvironment()
                                              .getScreenDevices();
    for (final GraphicsDevice gd : sds) {
        fail = true;
        Robot robot = new Robot(gd);
        robot.setAutoDelay(100);
        robot.setAutoWaitForIdle(true);

        Frame frame = new Frame(gd.getDefaultConfiguration());
        frame.setUndecorated(true);
        frame.setSize(400, 400);
        frame.setVisible(true);
        robot.waitForIdle();

        frame.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                System.out.println("e = " + e);
                fail = false;
            }
        });

        Rectangle bounds = frame.getBounds();
        robot.mouseMove(bounds.x + bounds.width / 2,
                        bounds.y + bounds.height / 2);
        robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK);
        frame.dispose();
        if (fail) {
            System.err.println("Frame bounds = " + bounds);
            throw new RuntimeException("Click in the wrong location");
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:MultiScreenRobotPosition.java

示例14: test

import java.awt.Robot; //导入方法依赖的package包/类
private static void test(final int mask) throws Exception {
    final Robot r = new Robot();
    r.setAutoDelay(100);
    r.setAutoWaitForIdle(true);

    EventQueue.invokeAndWait(MouseModifiersInKeyEvent::createAndShowGUI);
    r.waitForIdle();
    EventQueue.invokeAndWait(() -> bounds = f.getBounds());

    r.mouseMove(bounds.x + bounds.width / 2, bounds.y + bounds.height / 2);
    r.mousePress(mask);
    r.keyPress(KeyEvent.VK_A);
    r.keyRelease(KeyEvent.VK_A);

    EventQueue.invokeAndWait(() -> f.dispose());

    r.mouseRelease(mask);

    // all extended modifiers should work
    if (modifiersEX != mask) {
        System.err.println("Expected modifiersEX: " + mask);
        System.err.println("Actual modifiersEX: " + modifiersEX);
        throw new RuntimeException();
    }
    // old modifiers work only for button1
    if (modifiersEX == InputEvent.BUTTON1_DOWN_MASK) {
        if (modifiers != InputEvent.BUTTON1_MASK) {
            System.err.println("Expected modifiers: " + InputEvent.BUTTON1_MASK);
            System.err.println("Actual modifiers: " + modifiers);
            throw new RuntimeException();
        }
    }
    modifiersEX = 0;
    modifiers = 0;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:MouseModifiersInKeyEvent.java

示例15: checkAltClickEvent

import java.awt.Robot; //导入方法依赖的package包/类
private void checkAltClickEvent(int eventToCheck) throws InterruptedException, InvocationTargetException, AWTException {
    events = eventToCheck;
    tclear();
    Point locationButton = EventQueueWait.call_noexc(button, "getLocationOnScreen");
    Dimension sizeButton = EventQueueWait.call_noexc(button, "getSize");
    Point locationTextArea = EventQueueWait.call_noexc(actionsArea, "getLocationOnScreen");
    Dimension sizeTextArea = EventQueueWait.call_noexc(actionsArea, "getSize");

    Robot robot = new Robot();
    robot.setAutoDelay(10);
    robot.setAutoWaitForIdle(true);
    robot.mouseMove(locationTextArea.x + sizeTextArea.width / 2, locationTextArea.y + sizeTextArea.height / 2);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    robot.mouseMove(locationButton.x + sizeButton.width / 2 + 1, locationButton.y + sizeButton.height / 2 + 1);
    robot.mouseMove(locationButton.x + sizeButton.width / 2, locationButton.y + sizeButton.height / 2);
    robot.keyPress(KeyEvent.VK_ALT);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    robot.keyRelease(KeyEvent.VK_ALT);
    robot.mouseMove(locationTextArea.x + sizeTextArea.width / 2, locationTextArea.y + sizeTextArea.height / 2);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    new EventQueueWait() {
        @Override public boolean till() {
            return actionsArea.getText().length() > 0;
        }
    }.wait("Waiting for actionsArea failed?");
    String expected = weTextArea.getText();
    tclear();
    System.err.println("================================");
    System.err.println(expected);
    System.err.println("=================================");
    new Actions(driver).moveToElement(weButton).keyDown(Keys.ALT).click().keyUp(Keys.ALT).moveToElement(weTextArea).perform();
    AssertJUnit.assertEquals(expected, weTextArea.getText());
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:37,代码来源:NativeEventsTest.java


注:本文中的java.awt.Robot.setAutoWaitForIdle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。