本文整理汇总了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!");
}
}
示例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!");
}
}
示例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!");
}
}
示例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!");
}
}