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


Java InvocationEvent.getException方法代码示例

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


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

示例1: invokeAndWaitLowPriority

import java.awt.event.InvocationEvent; //导入方法依赖的package包/类
/**
 * Similar to {@link EventQueue#invokeAndWait} but posts the event at the same
 * priority as paint requests, to avoid bad visual artifacts.
 */
static void invokeAndWaitLowPriority(RWLock m, Runnable r)
        throws InterruptedException, InvocationTargetException {
    Toolkit t = Toolkit.getDefaultToolkit();
    EventQueue q = t.getSystemEventQueue();
    Object lock = new PaintPriorityEventLock();
    InvocationEvent ev = new PaintPriorityEvent(m, t, r, lock, true);
    synchronized (lock) {
        q.postEvent(ev);
        lock.wait();
    }
    Exception e = ev.getException();
    if (e != null) {
        throw new InvocationTargetException(e);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:EventLock.java

示例2: invokeLater

import java.awt.event.InvocationEvent; //导入方法依赖的package包/类
public static void invokeLater(Runnable event, Component component)
        throws InvocationTargetException {
    final InvocationEvent invocationEvent =
            new InvocationEvent(component != null ? component : Toolkit.getDefaultToolkit(), event);

    if (component != null) {
        final AppContext appContext = SunToolkit.targetToAppContext(component);
        SunToolkit.postEvent(appContext, invocationEvent);

        // 3746956 - flush events from PostEventQueue to prevent them from getting stuck and causing a deadlock
        SunToolkit.flushPendingEvents(appContext);
    } else {
        // This should be the equivalent to EventQueue.invokeAndWait
        ((LWCToolkit)Toolkit.getDefaultToolkit()).getSystemEventQueueForInvokeAndWait().postEvent(invocationEvent);
    }

    final Throwable eventException = invocationEvent.getException();
    if (eventException == null) return;

    if (eventException instanceof UndeclaredThrowableException) {
        throw new InvocationTargetException(((UndeclaredThrowableException)eventException).getUndeclaredThrowable());
    }
    throw new InvocationTargetException(eventException);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:LWCToolkit.java

示例3: invokeAndWait

import java.awt.event.InvocationEvent; //导入方法依赖的package包/类
/**
 * Causes runnable to have its run method called in the dispatch thread of the
 * 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.
 *
 * @exception InterruptedException If another thread has interrupted
 * this thread.
 * @exception InvocationTargetException If an exception is thrown when running
 * runnable.
 *
 * @since 1.2
 */
public static void invokeAndWait(Runnable runnable)
  throws InterruptedException, InvocationTargetException
{
  if (isDispatchThread ())
    throw new Error("Can't call invokeAndWait from event dispatch thread");

  EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
  Object notifyObject = new Object();

  InvocationEvent ie =
    new InvocationEvent(eq, runnable, notifyObject, true);

  synchronized (notifyObject)
    {
      eq.postEvent(ie);
      notifyObject.wait();
    }

  Exception exception;

  if ((exception = ie.getException()) != null)
    throw new InvocationTargetException(exception);
}
 
开发者ID:vilie,项目名称:javify,代码行数:37,代码来源:EventQueue.java

示例4: invokeAndWait

import java.awt.event.InvocationEvent; //导入方法依赖的package包/类
/**
 * Causes runnable to have its run method called in the dispatch thread of the
 * 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.
 *
 * @exception InterruptedException If another thread has interrupted
 * this thread.
 * @exception InvocationTargetException If an exception is thrown when running
 * runnable.
 *
 * @since 1.2
 */
public static void invokeAndWait(Runnable runnable)
  throws InterruptedException, InvocationTargetException
{
  if (isDispatchThread ())
    throw new Error("Can't call invokeAndWait from event dispatch thread");

  EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue(); 
  Object notifyObject = new Object();

  InvocationEvent ie =
    new InvocationEvent(eq, runnable, notifyObject, true);

  synchronized (notifyObject)
    {
      eq.postEvent(ie);
      notifyObject.wait();
    }

  Exception exception;

  if ((exception = ie.getException()) != null)
    throw new InvocationTargetException(exception);
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:37,代码来源:EventQueue.java

示例5: invokeLater

import java.awt.event.InvocationEvent; //导入方法依赖的package包/类
public static void invokeLater(Runnable event, Component component) throws InvocationTargetException {
    final InvocationEvent invocationEvent =
            new InvocationEvent(component != null ? component : Toolkit.getDefaultToolkit(), event);

    if (component != null) {
        final AppContext appContext = SunToolkit.targetToAppContext(component);
        SunToolkit.postEvent(appContext, invocationEvent);

        // 3746956 - flush events from PostEventQueue to prevent them from getting stuck and causing a deadlock
        SunToolkit.flushPendingEvents(appContext);
    } else {
        // This should be the equivalent to EventQueue.invokeAndWait
        ((LWCToolkit)Toolkit.getDefaultToolkit()).getSystemEventQueueForInvokeAndWait().postEvent(invocationEvent);
    }

    final Throwable eventException = invocationEvent.getException();
    if (eventException == null) return;

    if (eventException instanceof UndeclaredThrowableException) {
        throw new InvocationTargetException(((UndeclaredThrowableException)eventException).getUndeclaredThrowable());
    }
    throw new InvocationTargetException(eventException);
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:24,代码来源:LWCToolkit.java

示例6: invokeAndWait

import java.awt.event.InvocationEvent; //导入方法依赖的package包/类
public static void invokeAndWait(Runnable runnable)
        throws InterruptedException, InvocationTargetException {

    if (isDispatchThread()) {
        throw new Error();
    }

    final Toolkit toolkit = Toolkit.getDefaultToolkit();
    final Object notifier = new Object();  //$NON-LOCK-1$
    InvocationEvent event = new InvocationEvent(
            toolkit, runnable, notifier, true);

    synchronized (notifier) {
        toolkit.getSystemEventQueueImpl().postEvent(event);
        notifier.wait();
    }

    Exception exception = event.getException();

    if (exception != null) {
        throw new InvocationTargetException(exception);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:24,代码来源:EventQueue.java

示例7: invokeLater

import java.awt.event.InvocationEvent; //导入方法依赖的package包/类
public static void invokeLater(Runnable event, Component component) throws InvocationTargetException {
    final InvocationEvent invocationEvent =
            new InvocationEvent(component != null ? component : Toolkit.getDefaultToolkit(), event);

    if (component != null) {
        final AppContext appContext = SunToolkit.targetToAppContext(component);
        SunToolkit.postEvent(appContext, invocationEvent);

        // 3746956 - flush events from PostEventQueue to prevent them from getting stuck and causing a deadlock
        sun.awt.SunToolkitSubclass.flushPendingEvents(appContext);
    } else {
        // This should be the equivalent to EventQueue.invokeAndWait
        ((LWCToolkit)Toolkit.getDefaultToolkit()).getSystemEventQueueForInvokeAndWait().postEvent(invocationEvent);
    }

    final Throwable eventException = invocationEvent.getException();
    if (eventException == null) return;

    if (eventException instanceof UndeclaredThrowableException) {
        throw new InvocationTargetException(((UndeclaredThrowableException)eventException).getUndeclaredThrowable());
    }
    throw new InvocationTargetException(eventException);
}
 
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:24,代码来源:LWCToolkit.java

示例8: invokeAndWait

import java.awt.event.InvocationEvent; //导入方法依赖的package包/类
/**
 * Kicks an event over to the appropriate eventqueue and waits for it to
 * finish To avoid deadlocking, we manually run the NSRunLoop while waiting
 * Any selector invoked using ThreadUtilities performOnMainThread will be
 * processed in doAWTRunLoop The InvocationEvent will call
 * LWCToolkit.stopAWTRunLoop() when finished, which will stop our manual
 * runloop Does not dispatch native events while in the loop
 */
public static void invokeAndWait(Runnable runnable, Component component)
        throws InvocationTargetException {
    final long mediator = createAWTRunLoopMediator();

    InvocationEvent invocationEvent =
            new InvocationEvent(component != null ? component : Toolkit.getDefaultToolkit(),
                    runnable,
                    () -> {
                        if (mediator != 0) {
                            stopAWTRunLoop(mediator);
                        }
                    },
                    true);

    if (component != null) {
        AppContext appContext = SunToolkit.targetToAppContext(component);
        SunToolkit.postEvent(appContext, invocationEvent);

        // 3746956 - flush events from PostEventQueue to prevent them from getting stuck and causing a deadlock
        SunToolkit.flushPendingEvents(appContext);
    } else {
        // This should be the equivalent to EventQueue.invokeAndWait
        ((LWCToolkit)Toolkit.getDefaultToolkit()).getSystemEventQueueForInvokeAndWait().postEvent(invocationEvent);
    }

    doAWTRunLoop(mediator, false);

    Throwable eventException = invocationEvent.getException();
    if (eventException != null) {
        if (eventException instanceof UndeclaredThrowableException) {
            eventException = ((UndeclaredThrowableException)eventException).getUndeclaredThrowable();
        }
        throw new InvocationTargetException(eventException);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:44,代码来源:LWCToolkit.java

示例9: checkException

import java.awt.event.InvocationEvent; //导入方法依赖的package包/类
/**
 * Checks if exception occurred while {@code InvocationEvent} was processed and rethrows it as
 * an {@code InvocationTargetException}
 *
 * @param event the event to check for an exception
 * @throws InvocationTargetException if exception occurred when event was processed
 */
private static void checkException(InvocationEvent event) throws InvocationTargetException {
    Throwable eventException = event.getException();
    if (eventException == null) return;

    if (eventException instanceof UndeclaredThrowableException) {
        eventException = ((UndeclaredThrowableException)eventException).getUndeclaredThrowable();
    }
    throw new InvocationTargetException(eventException);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:LWCToolkit.java

示例10: invokeAndWait

import java.awt.event.InvocationEvent; //导入方法依赖的package包/类
/**
 * Invokes action through EventQueue. Waits for it execution.
 *
 * @param action an action to be invoked.
 * @return a result of action
 * @throws TimeoutExpiredException if action was not executed in
 * "QueueTool.InvocationTimeout" milliseconds.
 */
public <R> R invokeAndWait(QueueAction<R> action) {

    class JemmyInvocationLock {
    }
    Object lock = new JemmyInvocationLock();
    InvocationEvent event
            = new JemmyInvocationEvent(Toolkit.getDefaultToolkit(),
                    action,
                    lock,
                    true);
    try {
        synchronized (lock) {
            getQueue().postEvent(event);
            while (!action.getFinished()) {
                lock.wait();
            }
        }
    } catch (InterruptedException e) {
        throw (new JemmyException("InterruptedException during "
                + action.getDescription()
                + " execution", e));
    }
    if (action.getException() != null) {
        throw (new JemmyException("Exception in " + action.getDescription(),
                action.getException()));
    }
    if (event.getException() != null) {
        throw (new JemmyException("Exception in " + action.getDescription(),
                event.getException()));
    }
    return action.getResult();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:41,代码来源:QueueTool.java

示例11: invokeAndWait

import java.awt.event.InvocationEvent; //导入方法依赖的package包/类
public static void invokeAndWait(Runnable runnable, Component component) throws InvocationTargetException {
    final long mediator = createAWTRunLoopMediator();

    InvocationEvent invocationEvent =
            new InvocationEvent(component != null ? component : Toolkit.getDefaultToolkit(),
                    runnable,
                    () -> {
                        if (mediator != 0) {
                            stopAWTRunLoop(mediator);
                        }
                    },
                    true);

    if (component != null) {
        AppContext appContext = SunToolkit.targetToAppContext(component);
        SunToolkit.postEvent(appContext, invocationEvent);

        // 3746956 - flush events from PostEventQueue to prevent them from getting stuck and causing a deadlock
        SunToolkit.flushPendingEvents(appContext);
    } else {
        // This should be the equivalent to EventQueue.invokeAndWait
        ((LWCToolkit)Toolkit.getDefaultToolkit()).getSystemEventQueueForInvokeAndWait().postEvent(invocationEvent);
    }

    doAWTRunLoop(mediator, false);

    Throwable eventException = invocationEvent.getException();
    if (eventException != null) {
        if (eventException instanceof UndeclaredThrowableException) {
            eventException = ((UndeclaredThrowableException)eventException).getUndeclaredThrowable();
        }
        throw new InvocationTargetException(eventException);
    }
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:35,代码来源:LWCToolkit.java

示例12: invokeAndWait

import java.awt.event.InvocationEvent; //导入方法依赖的package包/类
public static void invokeAndWait(Runnable runnable, Component component) throws InvocationTargetException {
    final long mediator = createAWTRunLoopMediator();

    InvocationEvent invocationEvent = AWTAccessor.getInvocationEventAccessor()
            .createEvent(component != null ? component : Toolkit.getDefaultToolkit(),
                    runnable,
                    new Runnable() {
                        @Override
                        public void run() {
                            if (mediator != 0) {
                                stopAWTRunLoop(mediator);
                            }
                        }
                    },
                    true);

    if (component != null) {
        AppContext appContext = SunToolkit.targetToAppContext(component);
        SunToolkit.postEvent(appContext, invocationEvent);

        // 3746956 - flush events from PostEventQueue to prevent them from getting stuck and causing a deadlock
        sun.awt.SunToolkitSubclass.flushPendingEvents(appContext);
    } else {
        // This should be the equivalent to EventQueue.invokeAndWait
        ((LWCToolkit)Toolkit.getDefaultToolkit()).getSystemEventQueueForInvokeAndWait().postEvent(invocationEvent);
    }

    doAWTRunLoop(mediator, false);

    Throwable eventException = invocationEvent.getException();
    if (eventException != null) {
        if (eventException instanceof UndeclaredThrowableException) {
            eventException = ((UndeclaredThrowableException)eventException).getUndeclaredThrowable();
        }
        throw new InvocationTargetException(eventException);
    }
}
 
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:38,代码来源:LWCToolkit.java

示例13: invokeAndWait

import java.awt.event.InvocationEvent; //导入方法依赖的package包/类
public static void invokeAndWait(Runnable event, Component component) throws InterruptedException, InvocationTargetException {
    final long mediator = createAWTRunLoopMediator();

    InvocationEvent invocationEvent =
            new InvocationEvent(component != null ? component : Toolkit.getDefaultToolkit(), event) {
                @Override
                public void dispatch() {
                    try {
                        super.dispatch();
                    } finally {
                        if (mediator != 0) {
                            stopAWTRunLoop(mediator);
                        }
                    }
                }
            };

    if (component != null) {
        AppContext appContext = SunToolkit.targetToAppContext(component);
        SunToolkit.postEvent(appContext, invocationEvent);

        // 3746956 - flush events from PostEventQueue to prevent them from getting stuck and causing a deadlock
        sun.awt.SunToolkitSubclass.flushPendingEvents(appContext);
    } else {
        // This should be the equivalent to EventQueue.invokeAndWait
        ((LWCToolkit)Toolkit.getDefaultToolkit()).getSystemEventQueueForInvokeAndWait().postEvent(invocationEvent);
    }

    doAWTRunLoop(mediator, false);

    Throwable eventException = invocationEvent.getException();
    if (eventException != null) {
        if (eventException instanceof UndeclaredThrowableException) {
            eventException = ((UndeclaredThrowableException)eventException).getUndeclaredThrowable();
        }
        throw new InvocationTargetException(eventException);
    }
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:39,代码来源:LWCToolkit.java

示例14: invokeAndWait

import java.awt.event.InvocationEvent; //导入方法依赖的package包/类
/**
 * Submit event to the event queue as the method above
 * @param processEvents if <code>true<code/>  always process system events
 */
public static void invokeAndWait(Runnable runnable, Component component, boolean processEvents)
        throws InvocationTargetException
{
    boolean nonBlockingRunLoop;

    if (!processEvents) {
        synchronized (priorityInvocationPending) {
            nonBlockingRunLoop = priorityInvocationPending.get();
            if (!nonBlockingRunLoop) blockingRunLoopCounter.incrementAndGet();
        }
    }
    else {
        nonBlockingRunLoop = true;
    }

    final long mediator = createAWTRunLoopMediator();

    InvocationEvent invocationEvent =
            new InvocationEvent(component != null ? component : Toolkit.getDefaultToolkit(),
                    runnable,
                    () -> {
                        if (mediator != 0) {
                            stopAWTRunLoop(mediator);
                        }
                    },
                    true);

    if (!SelectorPerformer.offer(invocationEvent)) {
        if (component != null) {
            AppContext appContext = SunToolkit.targetToAppContext(component);
            SunToolkit.postEvent(appContext, invocationEvent);

            // 3746956 - flush events from PostEventQueue to prevent them from getting stuck and causing a deadlock
            SunToolkit.flushPendingEvents(appContext);
        } else {
            // This should be the equivalent to EventQueue.invokeAndWait
            ((LWCToolkit) Toolkit.getDefaultToolkit()).getSystemEventQueueForInvokeAndWait().postEvent(invocationEvent);
        }
    }

    doAWTRunLoop(mediator, nonBlockingRunLoop);
    if (!nonBlockingRunLoop) blockingRunLoopCounter.decrementAndGet();

    Throwable eventException = invocationEvent.getException();
    if (eventException != null) {
        if (eventException instanceof UndeclaredThrowableException) {
            eventException = ((UndeclaredThrowableException)eventException).getUndeclaredThrowable();
        }
        throw new InvocationTargetException(eventException);
    }
}
 
开发者ID:JetBrains,项目名称:jdk8u_jdk,代码行数:56,代码来源:LWCToolkit.java


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