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


Java Util.createRobot方法代码示例

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


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

示例1: runTests

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
void runTests()
{
    Frame frame = new Frame("frame");
    frame.setBounds(100, 100, 100, 100);
    frame.setVisible(true);
    frame.validate();
    Util.waitTillShown(frame);

    Robot robot = Util.createRobot();
    robot.setAutoDelay(10);

    oneButtonPressRelease(frame, robot, false, 1);
    oneButtonPressRelease(frame, robot, true, 0);
    twoButtonPressRelease(frame, robot, false, 2);
    twoButtonPressRelease(frame, robot, true, 1);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:MouseClickTest.java

示例2: main

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public static void main(String[] args) {
    PaintSetEnabledDeadlock frame = new PaintSetEnabledDeadlock();
    frame.setSize(200, 200);
    frame.setVisible(true);

    Robot robot = Util.createRobot();
    robot.setAutoDelay(100);
    robot.setAutoWaitForIdle(true);

    for (int i = 0; i < 20; ++i) {
        Util.clickOnComp(frame.panel, robot);
        Util.clickOnComp(frame.button, robot);
    }

    boolean ret = frame.panel.stop();
    frame.dispose();

    if (!ret) {
        throw new RuntimeException("Test failed!");
    }
    System.out.println("Test passed.");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:PaintSetEnabledDeadlock.java

示例3: FileListBetweenJVMsTest

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public FileListBetweenJVMsTest (Point targetFrameLocation, Point dragSourcePoint,
        int transferredFilesNumber)
        throws InterruptedException
{
    TargetFileListFrame targetFrame = new TargetFileListFrame(targetFrameLocation,
            transferredFilesNumber);

    Util.waitForIdle(null);

    final Robot robot = Util.createRobot();

    robot.mouseMove((int)dragSourcePoint.getX(),(int)dragSourcePoint.getY());
    sleep(100);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    sleep(100);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    sleep(100);

    Util.drag(robot, dragSourcePoint, targetFrame.getDropTargetPoint(),
            InputEvent.BUTTON1_MASK);

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

示例4: URIListBetweenJVMsTest

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public URIListBetweenJVMsTest (Point targetFrameLocation, Point dragSourcePoint,
        int transferredFilesNumber)
        throws InterruptedException
{
    TargetFileListFrame targetFrame = new TargetFileListFrame(targetFrameLocation,
            transferredFilesNumber);

    Util.waitForIdle(null);

    final Robot robot = Util.createRobot();

    robot.mouseMove((int)dragSourcePoint.getX(),(int)dragSourcePoint.getY());
    sleep(100);
    robot.mousePress(InputEvent.BUTTON1_MASK);
    sleep(100);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    sleep(100);

    Util.drag(robot, dragSourcePoint, targetFrame.getDropTargetPoint(),
            InputEvent.BUTTON1_MASK);

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:URIListBetweenJVMsTest.java

示例5: main

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    try {
        Robot r = Util.createRobot();
        r.setAutoDelay(200);
        r.setAutoWaitForIdle(true);
        r.mouseMove(0, 0);
        SwingUtilities.invokeAndWait(DisabledComponentsTest::init);
        Util.waitForIdle(r);
        Util.pointOnComp(b, r);
        if (entered.get()) {
            throw new RuntimeException("TEST FAILED: disabled button received MouseEntered event");
        }
        Util.clickOnComp(b, r);
        if (pressed.get()) {
            throw new RuntimeException("TEST FAILED: disabled button received MousePressed event");
        }
    } finally {
        if (frame != null) {
            frame.dispose();
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:DisabledComponentsTest.java

示例6: init

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public void init() {
    robot = Util.createRobot();

    // Create instructions for the user here, as well as set up
    // the environment -- set the layout manager, add buttons,
    // etc.
    this.setLayout (new BorderLayout ());
    Sysout.createDialogWithInstructions(new String[]
        {"This is an automatic test. Simply wait until it is done."
        });
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:ClearLwQueueBreakTest.java

示例7: main

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public static void main(String[] args) {
    Robot robot = Util.createRobot();

    Frame frame = new Frame("Frame");
    frame.setBackground(Color.BLUE);
    frame.setBounds(200, 50, 300, 300);
    frame.setVisible(true);

    Dialog dialog1 = new Dialog(frame, "Dialog 1", false);
    dialog1.setBackground(Color.RED);
    dialog1.setBounds(100, 100, 200, 200);
    dialog1.setVisible(true);

    Dialog dialog2 = new Dialog(frame, "Dialog 2", false);
    dialog2.setBackground(Color.GREEN);
    dialog2.setBounds(400, 100, 200, 200);
    dialog2.setVisible(true);

    Util.waitForIdle(robot);

    Util.clickOnComp(dialog2, robot);
    Util.waitForIdle(robot);

    Point point = dialog1.getLocationOnScreen();
    int x = point.x + (int)(dialog1.getWidth() * 0.9);
    int y = point.y + (int)(dialog1.getHeight() * 0.9);

    try {
        if (!Util.testPixelColor(x, y, dialog1.getBackground(), 10, 100, robot)) {
            throw new RuntimeException("Test FAILED: Dialog is behind the frame");
        }
    } finally {
        frame.dispose();
        dialog1.dispose();
        dialog2.dispose();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:DialogAboveFrameTest.java

示例8: startRegTest

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
private static Thread startRegTest(final Frame f) {
    Thread robot = new Thread(new Runnable() {
        public void run() {
            Robot r = Util.createRobot();
            dragWindow(f, 100, 100, r);
            // wait for the location to be set.
            sleepFor(2000);

            final Point l2 = f.getLocationOnScreen();

            // double click should maximize the frame
            doubleClick(r);

            // wait for location again.
            sleepFor(2000);
            final Point l3 = f.getLocationOnScreen();
            if (l3.equals(l2)) {
                throw new RuntimeException("Bad location after maximize. Window location has not moved");
            }
        }
    });
    return robot;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:MutterMaximizeTest.java

示例9: main

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public static void main(String args[]) throws InvocationTargetException, InterruptedException {
    if (Util.getWMID() != Util.METACITY_WM) {
        System.out.println("This test is only useful on Metacity");
        return;
    }
    robot = Util.createRobot();
    Util.waitForIdle(robot);
    final FullscreenDialogModality frame = new FullscreenDialogModality();
    frame.setUndecorated(true);
    frame.setBackground(Color.green);
    frame.setSize(500, 500);
    frame.setVisible(true);
    try {
        robot.delay(100);
        Util.waitForIdle(robot);

        EventQueue.invokeAndWait(new Runnable() {
            public void run() {
                frame.enterFS();
            }
        });
        robot.delay(200);
        Util.waitForIdle(robot);

        frame.checkDialogModality();

        EventQueue.invokeAndWait(new Runnable() {
            public void run() {
                frame.exitFS();
            }
        });
    } finally {
        frame.dispose();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:FullscreenDialogModality.java

示例10: init

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public void init() {
    robot = Util.createRobot();
    kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
        public void eventDispatched(AWTEvent event) {
            System.out.println("--> " + event);
        }
    }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:ContainerFocusAutoTransferTest.java

示例11: init

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public void init() {
    robot = Util.createRobot();
    frame.add(b0);
    frame.add(b1);
    frame.add(b2);
    frame.setLayout(new FlowLayout());
    frame.pack();

    b1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            b1.setEnabled(false);
            b2.setEnabled(false);
        }
    });
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:NoAutotransferToDisabledCompTest.java

示例12: init

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public void init() {
    robot = Util.createRobot();

    frame.setLayout(new FlowLayout());
    frame.setSize(200, 200);
    frame.add(fButton);

    window.setLocation(300, 0);
    window.add(wButton);
    window.pack();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:FocusOwnerFrameOnClick.java

示例13: init

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
private static void init()
{
    //*** Create instructions for the user here ***

    String[] instructions =
    {
        "This is an AUTOMATIC test, simply wait until it is done.",
        "The result (passed or failed) will be shown in the",
        "message window below."
    };
    Sysout.createDialog( );
    Sysout.printInstructions( instructions );

    JFrame f = new JFrame("LW menu test");

    JMenuBar menubar = new JMenuBar();
    f.setJMenuBar(menubar);

    // Create lightweight-enabled menu
    JMenu lmenu = new JMenu("Lite Menu");
    lmenu.add("Salad");
    lmenu.add( new AbstractAction("Fruit Plate") {
        public void actionPerformed(ActionEvent e) {
            failed = false;
        }
    });
    lmenu.add("Water");
    menubar.add(lmenu);

    // Create Heavyweight AWT Button
    Button heavy = new Button("  Heavyweight Button  ");

    // Add heavy button to box
    Box box = Box.createVerticalBox();
    box.add(Box.createVerticalStrut(20));
    box.add(heavy);
    box.add(Box.createVerticalStrut(20));

    f.getContentPane().add("Center", box);

    f.pack();
    f.show();

    Robot robot = Util.createRobot();
    robot.setAutoDelay(20);

    Util.waitForIdle(robot);

    // Activate the menu
    Point lLoc = lmenu.getLocationOnScreen();
    robot.mouseMove(lLoc.x + 5, lLoc.y + 5);

    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    Util.waitForIdle(robot);


    // Click on the "Fruit Plate" menu item.
    //    It's assumed that the menu item is located
    //    above the heavyweight button.
    Point bLoc = heavy.getLocationOnScreen();
    robot.mouseMove(bLoc.x + 10, bLoc.y + 5);

    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    Util.waitForIdle(robot);

    if (failed) {
        LWPopupMenu.fail("The LW menu item did not received the click.");
    } else {
        LWPopupMenu.pass();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:74,代码来源:LWPopupMenu.java

示例14: init

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
private static void init() {

        //*** Create instructions for the user here ***

        String[] instructions =
        {
            "This is an AUTOMATIC test, simply wait until it is done.",
            "The result (passed or failed) will be shown in the",
            "message window below."
        };
        Sysout.createDialog( );
        Sysout.printInstructions( instructions );

        // Turn off the dynamic layouting
        Toolkit.getDefaultToolkit().setDynamicLayout(false);
        System.out.println("isDynamicLayoutActive(): " + Toolkit.getDefaultToolkit().isDynamicLayoutActive());


        final Frame frame = new Frame("Test Frame");

        // Add some components to check their position later
        JPanel panel = new JPanel();
        panel.setBackground(Color.RED);

        JTextField jf = new JTextField (10);
        JTextField jf1 = new JTextField (10);
        JButton jb = new JButton("Test");

        panel.add(jf);
        panel.add(jf1);
        panel.add(jb);
        frame.add(panel);

        frame.setSize(400, 400);
        frame.setVisible(true);

        Robot robot = Util.createRobot();
        robot.setAutoDelay(20);

        // To be sure the window is shown and packed
        Util.waitForIdle(robot);

        // The initial JTextField position. While resizing the position supposed to stay the same.
        Point loc1 = jf1.getLocation();

        System.out.println("The initial position of the JTextField is: " + loc1);

        Insets insets = frame.getInsets();
        if (insets.right == 0 || insets.bottom == 0) {
            System.out.println("The test environment must have non-zero right & bottom insets! The current insets are: " + insets);
            pass();
            return;
        }

        // Let's move the mouse pointer to the bottom-right coner of the frame (the "size-grip")
        Rectangle bounds = frame.getBounds();

        robot.mouseMove(bounds.x + bounds.width - 1, bounds.y + bounds.height - 1);

        // ... and start resizing
        robot.mousePress( InputEvent.BUTTON1_MASK );
        robot.mouseMove(bounds.x + bounds.width + 20, bounds.y + bounds.height + 15);
        Util.waitForIdle(robot);

        // And check whether the location of the JTextField has changed.
        Point loc2 = jf1.getLocation();
        System.out.println("Position of the JTextField while resizing is: " + loc2);

        robot.mouseRelease( InputEvent.BUTTON1_MASK );

        // Location of the component changed if relayouting has happened.
        if (!loc2.equals(loc1)) {
            fail("Location of a component has been changed.");
            return;
        }

        DynamicLayout.pass();

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

示例15: init

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public void init() {
    robot = Util.createRobot();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:4,代码来源:OwnedWindowFocusIMECrashTest.java


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