當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。