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


Java InvocationEvent.isDispatched方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:ExecutableInputMethodManager.java

示例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);
		}
	}
 
开发者ID:javalovercn,项目名称:j2se_for_android,代码行数:29,代码来源:EventQueue.java


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