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


Java SwingUtilities.invokeAndWait方法代码示例

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


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

示例1: showDialog

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
@BeforeMethod public void showDialog() throws Throwable {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame = new JFrame("My Dialog");
            frame.setName("dialog-1");
            Object[] listData = new Object[30];
            for (int i = 1; i <= listData.length; i++) {
                listData[i - 1] = "List Item - " + i;
            }
            JList list = new JList(listData);
            list.setName("list-1");
            frame.getContentPane().add(list);
            frame.pack();
            frame.setAlwaysOnTop(true);
            frame.setVisible(true);
        }
    });
    driver = new JavaAgent();
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:20,代码来源:JavaElementPropertyAccessorTest.java

示例2: executeCase

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
static void executeCase(String lookAndFeelString) throws Exception {
     if (tryLookAndFeel(lookAndFeelString)) {
     SwingUtilities.invokeAndWait(() -> {
        createDateSpinner();
        createAndShowUI();
    });

    robot.waitForIdle();
    testSpinner(false);
    cleanUp();

    SwingUtilities.invokeAndWait(() -> {
        createNumberSpinner();
        createAndShowUI();
    });

    robot.waitForIdle();
    testSpinner(true);
    cleanUp();
     }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:bug8008657.java

示例3: testCaseRTL

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private static void testCaseRTL(String shortenedLookAndFeelString)
        throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            if (colorCenter.equals(colorLeft)) {
                if (!colorCenter.equals(colorRight)) {
                    System.out.println("[" + shortenedLookAndFeelString
                            + "]: RTL orientation test passed");
                }
            } else {
                frame.dispose();
                String error = "[" + shortenedLookAndFeelString
                        + "]: [Error]: LTR orientation test failed";
                errorString += error;
                System.err.println(error);
            }
        }
    });
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:JProgressBarOrientationRobotTest.java

示例4: main

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public static void main(String[] args) throws Throwable {

        SwingUtilities.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                constructTestUI();
            }
        });

        Util.waitForIdle(null);
        try {
            Point loc = textArea.getLocationOnScreen();
            Util.drag(new Robot(),
                    new Point((int) loc.x + 3, (int) loc.y + 3),
                    new Point((int) loc.x + 40, (int) loc.y + 40),
                    InputEvent.BUTTON1_MASK);
        } catch (AWTException ex) {
            throw new RuntimeException("Could not initiate a drag operation");
        }
        Util.waitForIdle(null);
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:DisposeFrameOnDragTest.java

示例5: windowSetPosition

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public void windowSetPosition() throws Throwable {
    driver = new JavaDriver();
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
    });
    Window window = driver.manage().window();
    Point actual = window.getPosition();
    AssertJUnit.assertNotNull(actual);
    java.awt.Point expected = EventQueueWait.call(frame, "getLocation");
    AssertJUnit.assertEquals(expected.x, actual.x);
    AssertJUnit.assertEquals(expected.y, actual.y);
    window.setPosition(new Point(expected.x + 10, expected.y + 10));
    actual = window.getPosition();
    AssertJUnit.assertEquals(expected.x + 10, actual.x);
    AssertJUnit.assertEquals(expected.y + 10, actual.y);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:20,代码来源:JavaDriverTest.java

示例6: testExceptionThrownWhenDocumentIsBeingReadAWTNo

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public void testExceptionThrownWhenDocumentIsBeingReadAWTNo () throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            MyEx my = new MyEx();

            toThrow = my;

            DD.options = null;
            DD.toReturn = NotifyDescriptor.NO_OPTION;

            support.open();
            JEditorPane [] panes = support.getOpenedPanes();
            assertNull(panes);
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:CloneableEditorUserQuestionAsync2Test.java

示例7: performTest

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private void performTest(String fileName , String code, String[] expected) throws Exception {
    int[] caretPosition = new int[1];
    code = org.netbeans.modules.java.hints.spiimpl.TestUtilities.detectOffsets(code, caretPosition);
    prepareTest(fileName, code);
    final Context ctx = prepareContext(caretPosition[0]);
    final Map<String, List<ErrorDescription>> errorDescriptionsAt = new HashMap<String, List<ErrorDescription>>();

    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            Map<String, List<ErrorDescription>> edsAt = new JavaHintsPositionRefresher().getErrorDescriptionsAt(ctx, doc);
            errorDescriptionsAt.putAll(edsAt);
        }
    });

    Set<String> eds = new HashSet<String>();
    for (Entry<String, List<ErrorDescription>> e : errorDescriptionsAt.entrySet()) {
        for (ErrorDescription ed : e.getValue()) {
            eds.add(ed.toString().replace(":  ", "  :"));
        }
    }
    assertTrue("Provided error messages differ. " + eds, eds.containsAll(Arrays.asList(expected)));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:JavaHintsPositionRefresherTest.java

示例8: disposeDriver

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
@AfterMethod public void disposeDriver() throws Throwable {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame.setVisible(false);
            frame.dispose();
        }
    });
    if (driver != null) {
        driver.quit();
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:12,代码来源:JButtonHtmlTest.java

示例9: findElementsOfElement

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public void findElementsOfElement() throws Throwable {
    driver = new JavaDriver();
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
    });
    WebElement element = driver.findElement(By.name("box-panel"));
    AssertJUnit.assertNotNull(element);
    List<WebElement> clickMe = element.findElements(By.name("click-me"));
    AssertJUnit.assertNotNull(clickMe);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:14,代码来源:JavaDriverTest.java

示例10: cleanUp

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private static void cleanUp() throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            frame.dispose();
        }
    });
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:bug8008657.java

示例11: main

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    robot = new Robot();
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            createUI();
        }
    });

    robot.waitForIdle();
    executeTest();
    robot.delay(1000);
    dispose();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:TestJInternalFrameDispose.java

示例12: changeChildren

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
void changeChildren(final HeapWalkerNode[] children) {
    Runnable childrenChanger = new Runnable() {
        public void run() {
            AbstractHeapWalkerNode.this.children = children;
            indexes = null;
        }
    };
    if (!SwingUtilities.isEventDispatchThread()) {
        try {
            SwingUtilities.invokeAndWait(childrenChanger);
        } catch (Exception ex) {}
    } else {
        childrenChanger.run();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:AbstractHeapWalkerNode.java

示例13: main

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {

        @Override
        public void run() {
            JFrame frame = new JFrame();
            frame.getContentPane().add(new JLabel("<html>a<title>"));
            frame.pack();
            frame.setVisible(true);
        }
    });
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:bug8034955.java

示例14: test

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private void test() throws Exception {
    Robot robot = new Robot();
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        UIManager.setLookAndFeel(info.getClassName());

        SwingUtilities.invokeAndWait(this);
        toolkit.realSync(); // after creation
        Thread.sleep(1000);

        Point point = this.bar.getLocation();
        SwingUtilities.convertPointToScreen(point, this.bar);
        point.x += this.bar.getWidth() >> 2;
        point.y += this.bar.getHeight() >> 1;
        robot.mouseMove(point.x, point.y);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);

        toolkit.realSync(); // before validation
        Thread.sleep(1000);
        SwingUtilities.invokeAndWait(this);

        if (this.bar != null) {
            this.bar = null; // allows to reuse the instance
            if (AUTO) { // error reporting only for automatic testing
                throw new Error("TEST FAILED");
            }
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:31,代码来源:Test7163696.java

示例15: runInAWT

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private static void runInAWT(Runnable r) {
    if (SwingUtilities.isEventDispatchThread()) {
        r.run();
    } else {
        try{
            SwingUtilities.invokeAndWait(r);
        }catch(Exception exc){
            throw new JemmyException("INVOKATION FAILED", exc);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:CompletionJListOperator.java


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