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


Java Robot.delay方法代码示例

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


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

示例1: moveTo

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

示例2: main

import java.awt.Robot; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    robot = new Robot();
    UIManager.LookAndFeelInfo[] lookAndFeelArray
            = UIManager.getInstalledLookAndFeels();
    for (UIManager.LookAndFeelInfo lookAndFeelItem : lookAndFeelArray) {
        String lookAndFeelString = lookAndFeelItem.getClassName();
        if (tryLookAndFeel(lookAndFeelString)) {
            createUI();
            robot.waitForIdle();
            executeTest();
            robot.delay(1000);
        }
    }
    if (!"".equals(errorMessage)) {
        throw new RuntimeException(errorMessage);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:TestJInternalFrameMaximize.java

示例3: mouseClickOnComp

import java.awt.Robot; //导入方法依赖的package包/类
static void mouseClickOnComp(Robot r, Component comp) {
    Point loc = comp.getLocationOnScreen();
    loc.x += comp.getWidth() / 2;
    loc.y += comp.getHeight() / 2;
    r.mouseMove(loc.x, loc.y);
    r.delay(10);
    r.mousePress(InputEvent.BUTTON1_MASK);
    r.delay(10);
    r.mouseRelease(InputEvent.BUTTON1_MASK);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:InputVerifierTest2.java

示例4: find

import java.awt.Robot; //导入方法依赖的package包/类
public static void find(String text,Robot robot) {
    Find op=new Find();
    robot.waitForIdle();
    java.awt.Point p=op.cboFindWhat().getLocationOnScreen();
    int x=p.x+op.cboFindWhat().getWidth()/2;
    int y=p.y+op.cboFindWhat().getHeight()/2;
    robot.mouseMove(x,y);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.delay(50);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    char c;
    boolean upper;
    for (int i=0;i < text.length();i++) {
        c=text.charAt(i);
        if (Character.isUpperCase(c)) {
            upper=true;
        } else {
            upper=false;
            c=(char)(Character.toUpperCase((char)c));
        }
        if (upper) {
            robot.keyPress(KeyEvent.VK_SHIFT);
        }
        robot.keyPress((int)c);
        robot.delay(5);
        robot.keyRelease((int)c);
        robot.delay(5);
        if (upper) {
            robot.keyRelease(KeyEvent.VK_SHIFT);
        }
    }
    p=op.btFind().getLocationOnScreen();
    x=p.x+op.btFind().getWidth()/2;
    y=p.y+op.btFind().getHeight()/2;
    robot.mouseMove(x,y);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.delay(50);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    robot.delay(50);
    robot.waitForIdle();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:42,代码来源:Find.java

示例5: main

import java.awt.Robot; //导入方法依赖的package包/类
public static void main(String s[]) throws Exception {
    PopupMenuTest obj = new PopupMenuTest();
    obj.createUI();
    robot = new Robot();
    robot.waitForIdle();
    robot.delay(1000);
    obj.exectuteTest();
    obj.dispose();
    if (isLightWeight) {
        throw new RuntimeException("Test Failed");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:PopupMenuTest.java

示例6: clickAt

import java.awt.Robot; //导入方法依赖的package包/类
/**
 * Move the mouse at (X,Y) screen position and then click the mouse button 1
 *
 * @param x the X coordinate
 * @param y the Y coordinate
 */
public void clickAt( int x, int y ) {

    Robot robot = getRobot();
    robot.mouseMove(x, y);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    robot.delay(500);
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:15,代码来源:LocalSystemOperations.java

示例7: clickOnTitle

import java.awt.Robot; //导入方法依赖的package包/类
public static void clickOnTitle(final Window decoratedWindow, final Robot robot) {
    if (decoratedWindow instanceof Frame || decoratedWindow instanceof Dialog) {
        Point p = getTitlePoint(decoratedWindow);
        robot.mouseMove(p.x, p.y);
        robot.delay(50);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.delay(50);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:Util.java

示例8: testCase

import java.awt.Robot; //导入方法依赖的package包/类
private static void testCase(final DefaultMutableTreeNode drag,
        final DefaultMutableTreeNode drop, final float shift)
        throws Exception {
    Robot robot = new Robot();
    robot.waitForIdle();
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            Rectangle rectDrag =
                    jTree.getPathBounds(new TreePath(drag.getPath()));
            dragPoint = new Point((int)rectDrag.getCenterX(),
                    (int) rectDrag.getCenterY());
            SwingUtilities.convertPointToScreen(dragPoint, jTree);
            Rectangle rectDrop =
                    jTree.getPathBounds(new TreePath(drop.getPath()));
            dropPoint = new Point(rectDrop.x + 5,
                    (int) (rectDrop.getCenterY() + shift * rectDrop.height));
            SwingUtilities.convertPointToScreen(dropPoint, jTree);
        }
    });

    robot.mouseMove(dragPoint.x, dragPoint.y);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.delay(1000);
    robot.mouseMove(dropPoint.x, dropPoint.y);
    robot.delay(1000);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    robot.delay(1000);
    robot.waitForIdle();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:LastNodeLowerHalfDrop.java

示例9: main

import java.awt.Robot; //导入方法依赖的package包/类
/**
 * @param args the command line arguments
 */
public static void main(String[] args) throws Exception {
    SwingUtilities.invokeAndWait(DemandGTK::createAndShow);
    Robot robot = new Robot();
    robot.waitForIdle();
    robot.delay(1000);
    SwingUtilities.invokeAndWait( () -> {
        frame.setVisible(false);
        frame.dispose();
    });

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:DemandGTK.java

示例10: main

import java.awt.Robot; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    robot = new Robot();
    robot.delay(1000);
    UIManager.LookAndFeelInfo[] lookAndFeelArray
            = UIManager.getInstalledLookAndFeels();
    for (UIManager.LookAndFeelInfo lookAndFeelItem : lookAndFeelArray) {
        executeCase(lookAndFeelItem.getClassName(),
                    lookAndFeelItem.getName());
    }
    if (!"".equals(errorString)) {
        throw new RuntimeException("Error Log:\n" + errorString);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:ScrollableTabbedPaneTest.java

示例11: main

import java.awt.Robot; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        // Windows only test
        if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS) {

            // Retrieving top edge of Desktop
            GraphicsConfiguration grConf = GraphicsEnvironment
                    .getLocalGraphicsEnvironment().getDefaultScreenDevice()
                    .getDefaultConfiguration();
            Rectangle scrRect = grConf.getBounds();
            Insets scrInsets = Toolkit.getDefaultToolkit().getScreenInsets(grConf);
            scrTop = scrRect.y + scrInsets.top;

            color = new Color(0, 255, 0);

            SwingUtilities.invokeAndWait(() -> {
                createAndShowUI();
            });

            try {
                Robot robot = new Robot();
                robot.setAutoDelay(500);
                robot.setAutoWaitForIdle(true);
                robot.delay(1000);

                // Resizing a window to invoke Windows Snap feature
                readFrameInfo();
                robot.mouseMove(frLoc.x + frSize.width / 2, frLoc.y);
                robot.mousePress(InputEvent.BUTTON1_MASK);
                robot.mouseMove(frLoc.x + frSize.width / 2, scrTop);
                robot.mouseRelease(InputEvent.BUTTON1_MASK);

                // Retrieving the color of window expanded area
                readFrameInfo();
                Insets insets = frame.getInsets();
                Color bgColor = robot.getPixelColor(frLoc.x + frSize.width / 2,
                        frLoc.y + frSize.height - insets.bottom - 1);

                frame.dispose();

                if (!bgColor.equals(color)) {
                    throw new RuntimeException("TEST FAILED: got "
                            + bgColor + " instead of " + color);
                }
                System.out.println("TEST PASSED!");
            } catch (AWTException ex) {
                throw new RuntimeException("TEST FAILED!");
            }
        }
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:51,代码来源:bug8016356.java

示例12: main

import java.awt.Robot; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    robot = new Robot();
    robot.delay(2000);
    UIManager.LookAndFeelInfo[] lookAndFeelArray
            = UIManager.getInstalledLookAndFeels();
    for (UIManager.LookAndFeelInfo lookAndFeelItem : lookAndFeelArray) {
        executeCase(lookAndFeelItem.getClassName());
    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:SelectEditTableCell.java

示例13: DefaultButtonModelCrashTest

import java.awt.Robot; //导入方法依赖的package包/类
public DefaultButtonModelCrashTest() throws Exception {
    try {
        Robot robot = new Robot();
        robot.setAutoDelay(200);
        SwingUtilities.invokeAndWait(() -> go());
        robot.waitForIdle();
        robot.keyPress(KeyEvent.VK_TAB);
        robot.keyRelease(KeyEvent.VK_TAB);
        robot.delay(100);
        robot.keyPress(KeyEvent.VK_TAB);
        robot.keyRelease(KeyEvent.VK_TAB);
    } finally {
        SwingUtilities.invokeAndWait(()->frame  .dispose());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:DefaultButtonModelCrashTest.java

示例14: init

import java.awt.Robot; //导入方法依赖的package包/类
public void init() throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            editorPane = new JEditorPane("text/html", "");
            editorPane.setEditable(false);
            editorPane.setMargin(new java.awt.Insets(0, 0, 0, 0));
            editorPane.setText(text);

            f = new JFrame();
            f.getContentPane().add(editorPane);
            f.setSize(600, 400);
            f.setVisible(true);
        }
    });
    blockTillDisplayed(editorPane);
    Robot robot  = new Robot();
    robot.waitForIdle();
    robot.delay(300);

    int x0 = p.x + 15 ;
    int y = p.y + 15;
    int match = 0;
    int nonmatch = 0;

    passed = true;
    for (int x = x0; x < x0 + 10; x++) {
        System.out.println("color ("+x+"," + y +")=" + robot.getPixelColor(x,y));
        if (!robot.getPixelColor(x, y).equals(new Color(0xcc, 0xcc, 0xcc))) {
            nonmatch++;
        } else match++;
    }
    if (nonmatch > match) {
        passed = false;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:bug4936917.java

示例15: main

import java.awt.Robot; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    robot = new Robot();
    robot.delay(2000);
    UIManager.LookAndFeelInfo[] lookAndFeelArray
            = UIManager.getInstalledLookAndFeels();
    for (UIManager.LookAndFeelInfo lookAndFeelItem : lookAndFeelArray) {
        executeCase(lookAndFeelItem.getClassName());
    }
    if (!"".equals(errorString)) {
        throw new RuntimeException("Error Log:\n" + errorString);
    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:JInternalFrameIconTest.java


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