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


Java Util.trackFocusGained方法代码示例

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


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

示例1: test1

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
void test1(final TestCase t) {
    Runnable action = new Runnable() {
        public void run() {
            KeyboardFocusManager.setCurrentKeyboardFocusManager(new TestKFM());
            if (t == TestCase.REMOVAL) {
                frame.remove(frame.panel0);

            } else if (t == TestCase.HIDING) {
                frame.panel0.setVisible(false);
            }
            frame.repaint();
        }
    };
    if (!Util.trackFocusGained(frame.b3, action, 2000, false)) {
        throw new TestFailedException(t + ": focus wasn't transfered as expected!");
    }
    KeyboardFocusManager.setCurrentKeyboardFocusManager(kfm);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:ContainerFocusAutoTransferTest.java

示例2: main

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public static void main(String[] args) {
    frame.setLayout(new GridLayout(3, 1));
    frame.add(btn1);
    frame.add(btn2);
    frame.add(btn3);
    frame.pack();
    frame.setVisible(true);

    Util.waitForIdle(null);

    if (!btn1.hasFocus()) {
        btn1.requestFocus();
        Util.waitForIdle(null);
        if (!btn1.hasFocus()) {
            throw new TestErrorException("couldn't focus " + btn1);
        }
    }

    if (!Util.trackFocusGained(btn3, new Runnable() {
            public void run() {
                btn3.requestFocus();
                frame.remove(btn1);
                frame.invalidate();
                            frame.validate();
                            frame.repaint();
            }
        }, 2000, true))
    {
        throw new TestFailedException("focus request on removal failed");
    }

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

示例3: test3

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
void test3(final TestCase t) {
    showFrame();
    Runnable action = new Runnable() {
        public void run() {
            if (t == TestCase.DISABLING) {
                frame.b0.setEnabled(false);

            } else if (t == TestCase.DEFOCUSING) {
                frame.b0.setFocusable(false);
            }
        }};
    if (!Util.trackFocusGained(frame.b1, action, 2000, false)) {
        throw new TestFailedException(t + ": focus wasn't transfered as expected!");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:ContainerFocusAutoTransferTest.java

示例4: start

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public void start() {
    frame.setVisible(true);
    Util.waitTillShown(frame);

    // Show the dialog.
    robot.keyPress(KeyEvent.VK_TAB);
    robot.delay(50);
    robot.keyRelease(KeyEvent.VK_TAB);

    Util.waitForIdle(robot);

    // Dispose the dialog.
    Runnable action = new Runnable() {
        public void run() {
            dialog.dispose();
        }
    };
    if (!Util.trackFocusGained(tf1, action, 2000, false)) {
        throw new RuntimeException("Test failed: TAB was processed incorrectly!");
    }

    // Check for type-ability.
    robot.keyPress(KeyEvent.VK_A);
    robot.delay(50);
    robot.keyRelease(KeyEvent.VK_A);

    Util.waitForIdle(robot);

    if (tf1.getText().equals("")) {
        throw new RuntimeException("Test failed: couldn't type a char!");
    }
    System.out.println("Test passed.");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:34,代码来源:ConsumeNextKeyTypedOnModalShowTest.java

示例5: start

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public void start() {
    frame.setVisible(true);
    Util.waitForIdle(robot);

    window.setVisible(true);
    Util.waitForIdle(robot);

    if (!wButton.hasFocus()) {
        if (!Util.trackFocusGained(wButton, new Runnable() {
                public void run() {
                    Util.clickOnComp(wButton, robot);
                }
            }, 2000, false))
        {
            throw new TestErrorException("wButton didn't gain focus on showing");
        }
    }

    Runnable clickAction = new Runnable() {
            public void run() {
                Point loc = fButton.getLocationOnScreen();
                Dimension dim = fButton.getSize();

                robot.mouseMove(loc.x, loc.y + dim.height + 20);
                robot.delay(50);
                robot.mousePress(InputEvent.BUTTON1_MASK);
                robot.delay(50);
                robot.mouseRelease(InputEvent.BUTTON1_MASK);
            }
        };

    if (!Util.trackWindowGainedFocus(frame, clickAction, 2000, true)) {
        throw new TestFailedException("The frame wasn't focused on click");
    }

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

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

示例7: start

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public void start() {
    otherFrame.setVisible(true);
    Util.waitForIdle(robot);
    testFrame.setVisible(true);
    Util.waitForIdle(robot);

    robot.delay(1000); // additional delay is required

    if (!testButton.hasFocus()) {
        testButton.requestFocus();
        Util.waitForIdle(robot);
        if (!testButton.hasFocus()) {
            throw new TestErrorException("couldn't focus " + testButton);
        }
    }

    /*
     * Iconify the Frame. Test that focus switches properly.
     */
    Runnable action = new Runnable() {
        public void run() {
            testFrame.setExtendedState(Frame.ICONIFIED);
        }
    };
    if (!Util.trackFocusGained(otherButton, action, 2000, true)) {
        throw new TestFailedException("iconifying focused window didn't trigger focus change");
    }

    /*
     * Test that key events go into the focus owner.
     */
    action = new Runnable() {
        public void run() {
            robot.keyPress(KeyEvent.VK_SPACE);
            robot.delay(50);
            robot.keyRelease(KeyEvent.VK_SPACE);
        }
    };
    if (!Util.trackActionPerformed(otherButton, action, 2000, true)) {
        throw new TestFailedException("Java focus owner doesn't match to the native one");
    }

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

示例8: start

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
@Override
public void start() {

    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
        public void eventDispatched(AWTEvent e) {
            System.err.println(e);
        }
    }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK);

    boolean gained = false;
    final Robot robot = Util.createRobot();

    JFrame frame1 = new JFrame("Main Frame");
    final JButton b1 = new JButton("button1");
    frame1.add(b1);
    frame1.pack();
    frame1.setLocation(0, 300);

    Util.showWindowWait(frame1);

    final JFrame frame2 = new JFrame("Test Frame");
    final JButton b2 = new JButton("button2");
    frame2.add(b2);
    frame2.pack();
    frame2.setLocation(300, 300);

    b2.setEnabled(false);
    b2.requestFocus();

    Util.showWindowWait(frame2);

    robot.delay(500);

    //
    // It's expeced that the focus is restored to <button1>.
    // If not, click <button1> to set focus on it.
    //
    if (!b1.hasFocus()) {
        gained = Util.trackFocusGained(b1, new Runnable() {
            public void run() {
                Util.clickOnComp(b1, robot);
            }
        }, 5000, false);

        if (!gained) {
            throw new RuntimeException("Unexpected state: focus is not on <button1>");
        }
    }

    robot.delay(500);

    //
    // Click <button2>, check that focus is set on the parent frame.
    //
    gained = false;
    gained = Util.trackFocusGained(frame2, new Runnable() {
        public void run() {
            Util.clickOnComp(b2, robot);
        }
    }, 5000, false);

    if (!gained) {
        throw new RuntimeException("Test failed: focus wasn't set to <frame2>");
    }

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


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