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


Java Util.trackWindowGainedFocus方法代码示例

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


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

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

示例2: start

import test.java.awt.regtesthelpers.Util; //导入方法依赖的package包/类
public void start() {
    final Frame frame = new Frame("Owner Frame");
    final Dialog dialog = new Dialog(frame, "Owned Dialog");

    frame.setSize(100, 100);
    dialog.setSize(100, 100);

    // Show the owner. Check that it's focused.
    if (!Util.trackWindowGainedFocus(frame, new Runnable() {
            public void run() {
                frame.setVisible(true);
            }
        }, 2000, false))
    {
        throw new TestErrorException("the owner frame hasn't been activated on show");
    }

    // Show the owned dialog. Check that it's focused.
    if (!Util.trackWindowGainedFocus(dialog, new Runnable() {
            public void run() {
                dialog.setVisible(true);
            }
        }, 2000, true))
    {
        throw new TestErrorException("the owned dialog hasn't been activated on show");
    }

    robot.delay(2000); // wait for the warning icon is shown

    // Close the dialog. Check that the owner is activated.
    if (!Util.trackWindowGainedFocus(frame, new Runnable() {
            public void run() {
                dialog.dispose();
            }
        }, 2000, false))
    {
        throw new TestFailedException("the owner hasn't been activated on closing the owned dialog");
    }

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


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