本文整理汇总了Java中java.awt.event.InvocationEvent.isDispatched方法的典型用法代码示例。如果您正苦于以下问题:Java InvocationEvent.isDispatched方法的具体用法?Java InvocationEvent.isDispatched怎么用?Java InvocationEvent.isDispatched使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.event.InvocationEvent
的用法示例。
在下文中一共展示了InvocationEvent.isDispatched方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showInputMethodMenuOnRequesterEDT
import java.awt.event.InvocationEvent; //导入方法依赖的package包/类
private void showInputMethodMenuOnRequesterEDT(Component requester)
throws InterruptedException, InvocationTargetException {
if (requester == null){
return;
}
class AWTInvocationLock {}
Object lock = new AWTInvocationLock();
InvocationEvent event =
new InvocationEvent(requester,
new Runnable() {
public void run() {
showInputMethodMenu();
}
},
lock,
true);
AppContext requesterAppContext = SunToolkit.targetToAppContext(requester);
synchronized (lock) {
SunToolkit.postEvent(requesterAppContext, event);
while (!event.isDispatched()) {
lock.wait();
}
}
Throwable eventThrowable = event.getThrowable();
if (eventThrowable != null) {
throw new InvocationTargetException(eventThrowable);
}
}
示例2: invokeAndWait
import java.awt.event.InvocationEvent; //导入方法依赖的package包/类
static void invokeAndWait(Object source, Runnable runnable)
throws InterruptedException, InvocationTargetException {
if (EventQueue.isDispatchThread()) {
// throw new Error("Cannot call invokeAndWait from the event dispatcher thread");
hc.core.util.LogManager.warning("exec Runnable.run in EventQueue.invokeAndWait at DispatchThread.");
runnable.run();
return;
}
class AWTInvocationLock {
}
Object lock = new AWTInvocationLock();
InvocationEvent event = new InvocationEvent(source, runnable, lock,
true);
synchronized (lock) {
Toolkit.getEventQueue().postEvent(event);
while (!event.isDispatched()) {
lock.wait();
}
}
Throwable eventThrowable = event.getThrowable();
if (eventThrowable != null) {
throw new InvocationTargetException(eventThrowable);
}
}