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


Java InvocationEvent.getThrowable方法代码示例

本文整理汇总了Java中java.awt.event.InvocationEvent.getThrowable方法的典型用法代码示例。如果您正苦于以下问题:Java InvocationEvent.getThrowable方法的具体用法?Java InvocationEvent.getThrowable怎么用?Java InvocationEvent.getThrowable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.event.InvocationEvent的用法示例。


在下文中一共展示了InvocationEvent.getThrowable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: invokeAndWait

import java.awt.event.InvocationEvent; //导入方法依赖的package包/类
/**
    * Causes <code>runnable</code> to have its <code>run</code>
    * method called in the dispatch thread of
    * {@link Toolkit#getSystemEventQueue the system EventQueue}.
    * This will happen after all pending events are processed.
    * The call blocks until this has happened.  This method
    * will throw an Error if called from the event dispatcher thread.
    *
    * @param runnable  the <code>Runnable</code> whose <code>run</code>
    *                  method should be executed
    *                  synchronously on the <code>EventQueue</code>
    * @exception       InterruptedException  if any thread has
    *                  interrupted this thread
    * @exception       InvocationTargetException  if an throwable is thrown
    *                  when running <code>runnable</code>
    * @see             #invokeLater
    * @since           1.2
    */
   public static void invokeAndWait(Runnable runnable)
            throws InterruptedException, InvocationTargetException {

       if (EventQueue.isDispatchThread()) {
           throw new Error("Cannot call invokeAndWait from the event dispatcher thread");
       }

class AWTInvocationLock {}
       Object lock = new AWTInvocationLock();

       InvocationEvent event = 
           new InvocationEvent(Toolkit.getDefaultToolkit(), runnable, lock,
			true);

       synchronized (lock) {
           Toolkit.getEventQueue().postEvent(event);
           lock.wait();
       }

       Throwable eventThrowable = event.getThrowable();
       if (eventThrowable != null) {
           throw new InvocationTargetException(eventThrowable);
       }
   }
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:43,代码来源:EventQueue.java

示例2: 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

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