本文整理汇总了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();
}
示例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();
}
}
示例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);
}
}
});
}
示例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);
}
示例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);
}
示例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);
}
});
}
示例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)));
}
示例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();
}
}
示例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);
}
示例10: cleanUp
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private static void cleanUp() throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
frame.dispose();
}
});
}
示例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();
}
示例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();
}
}
示例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);
}
});
}
示例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");
}
}
}
}
示例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);
}
}
}