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


Java Util.invokeOnEDT方法代码示例

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


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

示例1: main

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

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        Robot robot = new Robot();
        robot.setAutoDelay(50);

        SwingUtilities.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                createAndShowGUI();
            }
        });

        toolkit.realSync();

        Point pointToClick = Util.invokeOnEDT(new Callable<Point>() {

            @Override
            public Point call() throws Exception {
                return getCenterPoint(label);
            }
        });


        robot.mouseMove(pointToClick.x, pointToClick.y);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        toolkit.realSync();

        if (dragWindowMouseEnteredCount != 1) {
            throw new RuntimeException("No MouseEntered event on Drag Window!");
        }

        Point pointToDrag = Util.invokeOnEDT(new Callable<Point>() {

            @Override
            public Point call() throws Exception {
                button.addMouseListener(new ButtonMouseListener());
                return getCenterPoint(button);
            }
        });

        robot.mouseMove(pointToDrag.x, pointToDrag.y);
        toolkit.realSync();

        if (buttonMouseEnteredCount != 0) {
            throw new RuntimeException("Extra MouseEntered event on button!");
        }

        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        toolkit.realSync();

        if (labelMouseReleasedCount != 1) {
            throw new RuntimeException("No MouseReleased event on label!");
        }

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

示例2: main

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

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        Robot robot = new Robot();
        robot.setAutoDelay(50);

        SwingUtilities.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                createAndShowGUI();
            }
        });

        toolkit.realSync();

        Point pointToClick = Util.invokeOnEDT(new Callable<Point>() {

            @Override
            public Point call() throws Exception {
                return getCenterPoint(label);
            }
        });


        robot.mouseMove(pointToClick.x, pointToClick.y);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        toolkit.realSync();

        if (dragWindowMouseEnteredCount != 1 && dragWindowMouseExitedCount != 0) {
            throw new RuntimeException(
                    "Wrong number mouse Entered/Exited events on Drag Window!");
        }

        Point pointToDrag = Util.invokeOnEDT(new Callable<Point>() {

            @Override
            public Point call() throws Exception {
                label.addMouseListener(new LabelMouseListener());
                button.addMouseListener(new ButtonMouseListener());
                return getCenterPoint(button);
            }
        });

        robot.mouseMove(450, pointToClick.y);
        toolkit.realSync();

        if (labelMouseEnteredCount != 0 && labelMouseExitedCount != 1) {
            throw new RuntimeException(
                    "Wrong number Mouse Entered/Exited events on label!");
        }

        robot.mouseMove(450, pointToDrag.y);
        toolkit.realSync();

        if (labelMouseEnteredCount != 0 && labelMouseExitedCount != 1) {
            throw new RuntimeException(
                    "Wrong number Mouse Entered/Exited events on label!");
        }

        if (buttonMouseEnteredCount != 0 && buttonMouseExitedCount != 0) {
            throw new RuntimeException(
                    "Wrong number Mouse Entered/Exited events on button!");
        }

        robot.mouseMove(pointToDrag.y, pointToDrag.y);
        toolkit.realSync();

        if (buttonMouseEnteredCount != 1 && buttonMouseExitedCount != 0) {
            throw new RuntimeException(
                    "Wrong number Mouse Entered/Exited events on button!");
        }

        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        toolkit.realSync();

        if (labelMouseReleasedCount != 1) {
            throw new RuntimeException("No MouseReleased event on label!");
        }
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:81,代码来源:DragWindowOutOfFrameTest.java

示例3: main

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

        Robot robot = new Robot();
        robot.setAutoDelay(50);

        SwingUtilities.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                createAndShowGUI();
            }
        });

        robot.waitForIdle();

        Point pointToClick = Util.invokeOnEDT(new Callable<Point>() {

            @Override
            public Point call() throws Exception {
                return getCenterPoint(label);
            }
        });


        robot.mouseMove(pointToClick.x, pointToClick.y);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.waitForIdle();

        if (dragWindowMouseEnteredCount != 1) {
            throw new RuntimeException("No MouseEntered event on Drag Window!");
        }

        Point pointToDrag = Util.invokeOnEDT(new Callable<Point>() {

            @Override
            public Point call() throws Exception {
                button.addMouseListener(new ButtonMouseListener());
                return getCenterPoint(button);
            }
        });

        robot.mouseMove(pointToDrag.x, pointToDrag.y);
        robot.waitForIdle();

        if (buttonMouseEnteredCount != 0) {
            throw new RuntimeException("Extra MouseEntered event on button!");
        }

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

        if (labelMouseReleasedCount != 1) {
            throw new RuntimeException("No MouseReleased event on label!");
        }

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

示例4: main

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

        Robot robot = new Robot();
        robot.setAutoDelay(50);

        SwingUtilities.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                createAndShowGUI();
            }
        });

        robot.waitForIdle();

        Point pointToClick = Util.invokeOnEDT(new Callable<Point>() {

            @Override
            public Point call() throws Exception {
                return getCenterPoint(label);
            }
        });


        robot.mouseMove(pointToClick.x, pointToClick.y);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.waitForIdle();

        if (dragWindowMouseEnteredCount != 1 && dragWindowMouseExitedCount != 0) {
            throw new RuntimeException(
                    "Wrong number mouse Entered/Exited events on Drag Window!");
        }

        Point pointToDrag = Util.invokeOnEDT(new Callable<Point>() {

            @Override
            public Point call() throws Exception {
                label.addMouseListener(new LabelMouseListener());
                button.addMouseListener(new ButtonMouseListener());
                return getCenterPoint(button);
            }
        });

        robot.mouseMove(450, pointToClick.y);
        robot.waitForIdle();

        if (labelMouseEnteredCount != 0 && labelMouseExitedCount != 1) {
            throw new RuntimeException(
                    "Wrong number Mouse Entered/Exited events on label!");
        }

        robot.mouseMove(450, pointToDrag.y);
        robot.waitForIdle();

        if (labelMouseEnteredCount != 0 && labelMouseExitedCount != 1) {
            throw new RuntimeException(
                    "Wrong number Mouse Entered/Exited events on label!");
        }

        if (buttonMouseEnteredCount != 0 && buttonMouseExitedCount != 0) {
            throw new RuntimeException(
                    "Wrong number Mouse Entered/Exited events on button!");
        }

        robot.mouseMove(pointToDrag.y, pointToDrag.y);
        robot.waitForIdle();

        if (buttonMouseEnteredCount != 1 && buttonMouseExitedCount != 0) {
            throw new RuntimeException(
                    "Wrong number Mouse Entered/Exited events on button!");
        }

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

        if (labelMouseReleasedCount != 1) {
            throw new RuntimeException("No MouseReleased event on label!");
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:80,代码来源:DragWindowOutOfFrameTest.java


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