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


Java Util.clickOnComp方法代码示例

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


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

示例1: 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

示例2: testSetText

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
private void testSetText() {
    textArea.setText(null);
    textArea.requestFocus();
    Util.clickOnComp(textArea, robot);
    Util.waitForIdle(robot);
    robot.keyPress(KeyEvent.VK_A);
    robot.delay(5);
    robot.keyRelease(KeyEvent.VK_A);
    Util.waitForIdle(robot);
    textArea.setText(null);
    checkTest("");
    textArea.setText("CaseSensitive");
    checkTest("CaseSensitive");
    textArea.setText("caseSensitive");
    checkTest("caseSensitive");

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

示例3: test2

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
void test2(Window owner, Window child1, Window child2) {
    System.out.println("* * * STAGE 2 * * *\nWindow nowner: " + owner);

    owner.setFocusableWindowState(false);
    owner.setVisible(true);

    child1.setFocusableWindowState(true);
    child1.setVisible(true);

    child2.add(button);
    child2.setVisible(true);

    Util.waitTillShown(child2);

    Util.clickOnComp(button, robot);
    if (button == KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()) {
        throw new RuntimeException("Test failed.");
    }
    child2.dispose();
    child1.dispose();
    owner.dispose();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:NonfocusableOwnerTest.java

示例4: showFrame

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
void showFrame() {
    if (frame != null) {
        frame.dispose();
        Util.waitForIdle(robot);
    }
    frame = new TestFrame();
    frame.setVisible(true);
    Util.waitTillShown(frame);

    if (!frame.b0.hasFocus()) {
        Util.clickOnComp(frame.b0, robot);
        Util.waitForIdle(robot);
        if (!frame.b0.hasFocus()) {
            throw new TestErrorException("couldn't set focus on " + frame.b2);
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:ContainerFocusAutoTransferTest.java

示例5: test

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
private void test(Window toplevel, int stage) {
    toplevel.add(testButton);
    toplevel.pack();
    toplevel.setLocation(200, 0);

    switch (stage) {
        case 1:
            toplevel.setVisible(true);
            break;
        case 2:
            testToplevel = toplevel;
            Util.clickOnComp(showButton, robot);
            break;
    }
    Util.waitForIdle(robot);

    if (!Util.trackActionPerformed(testButton, action, 2000, false)) {
        throw new TestFailedException("Stage " + stage + ". The toplevel " + toplevel + " wasn't made foreground on showing");
    }
    System.out.println("Stage " + stage + ". Toplevel " + toplevel + " - passed");
    toplevel.dispose();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:ShowFrameCheckForegroundTest.java

示例6: 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

示例7: main

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public static void main(String[] args) {
    frame = new TestFrame("Test EDT access to Window components");
    window = new TestWindow(frame);

    SwingUtilities.invokeLater(WindowIsFocusableAccessByThreadsTest::init);

    Util.waitTillShown(frame);
    Robot robot = Util.createRobot();
    Util.clickOnComp(frame, robot, 100);
    Util.clickOnComp(openWindowBtn, robot, 100);

    Util.waitTillShown(window);

    if (!testPassed.get()) {
        throw new RuntimeException("Window component methods has been accessed not " +
                "from Event Dispatching Thread");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:WindowIsFocusableAccessByThreadsTest.java

示例8: main

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public static void main(String[] args) {
    Robot r = Util.createRobot();
    JWindow w = new JWindow();
    w.setSize(100, 100);
    w.setVisible(true);
    Util.waitForIdle(r);

    final JPopupMenu menu = new JPopupMenu();
    JButton item = new JButton("A button in popup");

    menu.add(item);

    w.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent me) {
            menu.show(me.getComponent(), me.getX(), me.getY());

            System.out.println("Showing menu at " + menu.getLocationOnScreen() +
                               " isVisible: " + menu.isVisible() +
                               " isValid: " + menu.isValid());
            }
        });

    Util.clickOnComp(w, r);
    Util.waitForIdle(r);

    if (!menu.isVisible()) {
        throw new RuntimeException("menu was not shown");
    }

    menu.hide();
    System.out.println("Test passed.");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:33,代码来源:GrabOnUnfocusableToplevel.java

示例9: testComponent

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
private static void testComponent(final Component comp){
    Runnable action = new Runnable(){
            public void run(){
                Util.clickOnComp(comp, robot);
                Util.waitForIdle(robot);
            }
        };

    if (! Util.trackFocusGained(comp, action, REASONABLE_PATH_TIME, true)){
        AbstractTest.fail("Focus didn't come to " + comp);
    }
    testKeys();
    Util.waitForIdle(robot);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:CorrectTime.java

示例10: setFocus

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
private static void setFocus(final Component comp, final Robot r) {
    if (comp.hasFocus()) {
        return;
    }

    Util.clickOnComp(comp, r);
    Util.waitForIdle(r);

    if (!comp.hasFocus()) {
        throw new RuntimeException("can not set focus on " + comp);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:TranserFocusToWindow.java

示例11: main

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    try {
        SwingUtilities.invokeAndWait(ChoiceLocationTest::initAndShowUI);
        Robot r = new Robot();
        r.waitForIdle();
        r.delay(100);

        Util.clickOnComp(choice, r);

        choice.addItemListener(event -> {throw new RuntimeException("Failed: the choice popup is in the wrong place");});

        // Test: click in several places on the top of the frame an ensure there' no choice there
        Point locOnScreen = frame.getLocationOnScreen();
        int x = locOnScreen.x + FRAME_SIZE / 2;
        for (int y = locOnScreen.y + frame.getInsets().top + 10; y < locOnScreen.y + FRAME_SIZE / 3 ; y += CLICK_STEP) {
            r.mouseMove(x, y);
            r.waitForIdle();
            r.mousePress(InputEvent.BUTTON1_MASK);
            r.mouseRelease(InputEvent.BUTTON1_MASK);
            r.waitForIdle();
            r.delay(100);
        }
    } finally {
        if (frame != null) {
            frame.dispose();
        }
    }

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

示例12: test

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
void test() {
    Util.clickOnComp(button, robot);
    if (!button.hasFocus()) {
        throw new TestErrorException("the button couldn't be focused by click");
    }
    Util.clickOnTitle(frame, robot); // here there was a crash
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:OwnedWindowFocusIMECrashTest.java

示例13: 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:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:38,代码来源:DialogAboveFrameTest.java

示例14: test1

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
void test1() {
    Util.clickOnComp(b, robot);
    Util.waitForIdle(robot);

    if (!tf2.hasFocus()) {
        throw new TestFailedException("target component didn't get focus!");
    }

    robot.keyPress(KeyEvent.VK_9);
    robot.delay(50);
    robot.keyRelease(KeyEvent.VK_9);

    synchronized (typed) {
        if (!Util.waitForCondition(typed, 2000)) {
            throw new TestFailedException("key char couldn't be typed!");
        }
    }

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

    if (!tf3.hasFocus()) {
        throw new Error("a text field couldn't be focused.");
    }

    typed.set(false);
    robot.keyPress(KeyEvent.VK_8);
    robot.delay(50);
    robot.keyRelease(KeyEvent.VK_8);

    synchronized (typed) {
        if (!Util.waitForCondition(typed, 2000)) {
            throw new TestFailedException("key char couldn't be typed!");
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:37,代码来源:ClearLwQueueBreakTest.java

示例15: main

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException, java.lang.reflect.InvocationTargetException
{
    final Frame frame = new Frame("the test");
    frame.setLayout(new FlowLayout());
    final Button btn1 = new Button("button 1");
    frame.add(btn1);
    frame.add(new Button("button 2"));
    frame.add(new Button("button 3"));
    frame.pack();
    frame.setVisible(true);

    Robot r = Util.createRobot();
    Util.waitForIdle(r);
    Util.clickOnComp(btn1, r);
    Util.waitForIdle(r);
    KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    if (kfm.getFocusOwner() != btn1) {
        throw new RuntimeException("test error: can not set focus on " + btn1 + ".");
    }

    EventQueue.invokeAndWait(new Runnable() {
            public void run() {
                final int n_comps = frame.getComponentCount();
                for (int i = 0; i < n_comps; ++i) {
                    frame.getComponent(i).setVisible(false);
                }
            }
        });
    Util.waitForIdle(r);
    final Component focus_owner = kfm.getFocusOwner();

    if (focus_owner != null && !focus_owner.isVisible()) {
        throw new RuntimeException("we have invisible focus owner");
    }
    System.out.println("test passed");
    frame.dispose();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:38,代码来源:RequestFocusAndHideTest.java


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