java类java.awt.event.InvocationEvent的实例源码

EventLock.java 文件源码 项目:incubator-netbeans 阅读 30 收藏 0 点赞 0 评论 0
/**
 * 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);
    }
}
LWCToolkit.java 文件源码 项目:OpenJSharp 阅读 30 收藏 0 点赞 0 评论 0
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);
}
WEmbeddedFrame.java 文件源码 项目:OpenJSharp 阅读 31 收藏 0 点赞 0 评论 0
@SuppressWarnings("deprecation")
public void synthesizeWindowActivation(final boolean activate) {
    if (!activate || EventQueue.isDispatchThread()) {
        ((WFramePeer)getPeer()).emulateActivation(activate);
    } else {
        // To avoid focus concurrence b/w IE and EmbeddedFrame
        // activation is postponed by means of posting it to EDT.
        Runnable r = new Runnable() {
            public void run() {
                ((WFramePeer)getPeer()).emulateActivation(true);
            }
        };
        WToolkit.postEvent(WToolkit.targetToAppContext(this),
                           new InvocationEvent(this, r));
    }
}
WComponentPeer.java 文件源码 项目:OpenJSharp 阅读 31 收藏 0 点赞 0 评论 0
public void replaceSurfaceDataLater() {
    Runnable r = new Runnable() {
        @Override
        public void run() {
            // Shouldn't do anything if object is disposed in meanwhile
            // No need for sync as disposeAction in Window is performed
            // on EDT
            if (!isDisposed()) {
                try {
                    replaceSurfaceData();
                } catch (InvalidPipeException e) {
                    // REMIND : what do we do if our surface creation failed?
                }
            }
        }
    };
    Component c = (Component)target;
    // Fix 6255371.
    if (!PaintEventDispatcher.getPaintEventDispatcher().queueSurfaceDataReplacing(c, r)) {
        postEvent(new InvocationEvent(c, r));
    }
}
LWCToolkit.java 文件源码 项目:jdk8u-jdk 阅读 33 收藏 0 点赞 0 评论 0
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);
}
WEmbeddedFrame.java 文件源码 项目:jdk8u-jdk 阅读 33 收藏 0 点赞 0 评论 0
@SuppressWarnings("deprecation")
public void synthesizeWindowActivation(final boolean activate) {
    if (!activate || EventQueue.isDispatchThread()) {
        ((WFramePeer)getPeer()).emulateActivation(activate);
    } else {
        // To avoid focus concurrence b/w IE and EmbeddedFrame
        // activation is postponed by means of posting it to EDT.
        Runnable r = new Runnable() {
            public void run() {
                ((WFramePeer)getPeer()).emulateActivation(true);
            }
        };
        WToolkit.postEvent(WToolkit.targetToAppContext(this),
                           new InvocationEvent(this, r));
    }
}
WComponentPeer.java 文件源码 项目:jdk8u-jdk 阅读 26 收藏 0 点赞 0 评论 0
public void replaceSurfaceDataLater() {
    Runnable r = new Runnable() {
        @Override
        public void run() {
            // Shouldn't do anything if object is disposed in meanwhile
            // No need for sync as disposeAction in Window is performed
            // on EDT
            if (!isDisposed()) {
                try {
                    replaceSurfaceData();
                } catch (InvalidPipeException e) {
                    // REMIND : what do we do if our surface creation failed?
                }
            }
        }
    };
    Component c = (Component)target;
    // Fix 6255371.
    if (!PaintEventDispatcher.getPaintEventDispatcher().queueSurfaceDataReplacing(c, r)) {
        postEvent(new InvocationEvent(c, r));
    }
}
LWCToolkit.java 文件源码 项目:openjdk-jdk10 阅读 31 收藏 0 点赞 0 评论 0
/**
 * Kicks an event over to the appropriate event queue 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
 * run loop. Does not dispatch native events while in the loop
 */
public static void invokeAndWait(Runnable runnable, Component component)
        throws InvocationTargetException {
    Objects.requireNonNull(component, "Null component provided to invokeAndWait");

    long mediator = createAWTRunLoopMediator();
    InvocationEvent invocationEvent =
            new InvocationEvent(component,
                    runnable,
                    () -> {
                        if (mediator != 0) {
                            stopAWTRunLoop(mediator);
                        }
                    },
                    true);

    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);
    doAWTRunLoop(mediator, false);

    checkException(invocationEvent);
}
WEmbeddedFrame.java 文件源码 项目:openjdk-jdk10 阅读 32 收藏 0 点赞 0 评论 0
public void synthesizeWindowActivation(final boolean activate) {
    final FramePeer peer = AWTAccessor.getComponentAccessor().getPeer(this);
    if (!activate || EventQueue.isDispatchThread()) {
        peer.emulateActivation(activate);
    } else {
        // To avoid focus concurrence b/w IE and EmbeddedFrame
        // activation is postponed by means of posting it to EDT.
        Runnable r = new Runnable() {
            public void run() {
                peer.emulateActivation(true);
            }
        };
        WToolkit.postEvent(WToolkit.targetToAppContext(this),
                           new InvocationEvent(this, r));
    }
}
WComponentPeer.java 文件源码 项目:openjdk-jdk10 阅读 25 收藏 0 点赞 0 评论 0
public void replaceSurfaceDataLater() {
    Runnable r = new Runnable() {
        @Override
        public void run() {
            // Shouldn't do anything if object is disposed in meanwhile
            // No need for sync as disposeAction in Window is performed
            // on EDT
            if (!isDisposed()) {
                try {
                    replaceSurfaceData();
                } catch (InvalidPipeException e) {
                    // REMIND : what do we do if our surface creation failed?
                }
            }
        }
    };
    Component c = (Component)target;
    // Fix 6255371.
    if (!PaintEventDispatcher.getPaintEventDispatcher().queueSurfaceDataReplacing(c, r)) {
        postEvent(new InvocationEvent(c, r));
    }
}
LWCToolkit.java 文件源码 项目:openjdk9 阅读 30 收藏 0 点赞 0 评论 0
/**
 * Kicks an event over to the appropriate event queue 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
 * run loop. Does not dispatch native events while in the loop
 */
public static void invokeAndWait(Runnable runnable, Component component)
        throws InvocationTargetException {
    Objects.requireNonNull(component, "Null component provided to invokeAndWait");

    long mediator = createAWTRunLoopMediator();
    InvocationEvent invocationEvent =
            new InvocationEvent(component,
                    runnable,
                    () -> {
                        if (mediator != 0) {
                            stopAWTRunLoop(mediator);
                        }
                    },
                    true);

    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);
    doAWTRunLoop(mediator, false);

    checkException(invocationEvent);
}
WEmbeddedFrame.java 文件源码 项目:openjdk9 阅读 29 收藏 0 点赞 0 评论 0
public void synthesizeWindowActivation(final boolean activate) {
    final FramePeer peer = AWTAccessor.getComponentAccessor().getPeer(this);
    if (!activate || EventQueue.isDispatchThread()) {
        peer.emulateActivation(activate);
    } else {
        // To avoid focus concurrence b/w IE and EmbeddedFrame
        // activation is postponed by means of posting it to EDT.
        Runnable r = new Runnable() {
            public void run() {
                peer.emulateActivation(true);
            }
        };
        WToolkit.postEvent(WToolkit.targetToAppContext(this),
                           new InvocationEvent(this, r));
    }
}
WComponentPeer.java 文件源码 项目:openjdk9 阅读 36 收藏 0 点赞 0 评论 0
public void replaceSurfaceDataLater() {
    Runnable r = new Runnable() {
        @Override
        public void run() {
            // Shouldn't do anything if object is disposed in meanwhile
            // No need for sync as disposeAction in Window is performed
            // on EDT
            if (!isDisposed()) {
                try {
                    replaceSurfaceData();
                } catch (InvalidPipeException e) {
                    // REMIND : what do we do if our surface creation failed?
                }
            }
        }
    };
    Component c = (Component)target;
    // Fix 6255371.
    if (!PaintEventDispatcher.getPaintEventDispatcher().queueSurfaceDataReplacing(c, r)) {
        postEvent(new InvocationEvent(c, r));
    }
}
LWCToolkit.java 文件源码 项目:jdk8u_jdk 阅读 29 收藏 0 点赞 0 评论 0
/**
 * Checks if there's an active SelectorPerformer corresponding to the invocation's AppContext,
 * adds the invocation to the SelectorPerformer's queue and returns true.
 * Otherwise does nothing and returns false.
 */
public static boolean offer(InvocationEvent invocation) {
    Object source = invocation.getSource();

    SelectorPerformer performer = (source instanceof Component) ?
            getInstance((Component)source) :
            getInstance(Toolkit.getDefaultToolkit().getSystemEventQueue());

    if (performer == null) return false;

    synchronized (performer.invocations) {
        if (!performer.invocations.isEmpty()) {
            performer.invocations.peek().add(invocation);
            return true;
        }
    }
    return false;
}
LWCToolkit.java 文件源码 项目:jdk8u_jdk 阅读 30 收藏 0 点赞 0 评论 0
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);
}
WEmbeddedFrame.java 文件源码 项目:jdk8u_jdk 阅读 30 收藏 0 点赞 0 评论 0
@SuppressWarnings("deprecation")
public void synthesizeWindowActivation(final boolean activate) {
    if (!activate || EventQueue.isDispatchThread()) {
        ((WFramePeer)getPeer()).emulateActivation(activate);
    } else {
        // To avoid focus concurrence b/w IE and EmbeddedFrame
        // activation is postponed by means of posting it to EDT.
        Runnable r = new Runnable() {
            public void run() {
                ((WFramePeer)getPeer()).emulateActivation(true);
            }
        };
        WToolkit.postEvent(WToolkit.targetToAppContext(this),
                           new InvocationEvent(this, r));
    }
}
WComponentPeer.java 文件源码 项目:jdk8u_jdk 阅读 32 收藏 0 点赞 0 评论 0
public void replaceSurfaceDataLater() {
    Runnable r = new Runnable() {
        @Override
        public void run() {
            // Shouldn't do anything if object is disposed in meanwhile
            // No need for sync as disposeAction in Window is performed
            // on EDT
            if (!isDisposed()) {
                try {
                    replaceSurfaceData();
                } catch (InvalidPipeException e) {
                    // REMIND : what do we do if our surface creation failed?
                }
            }
        }
    };
    Component c = (Component)target;
    // Fix 6255371.
    if (!PaintEventDispatcher.getPaintEventDispatcher().queueSurfaceDataReplacing(c, r)) {
        postEvent(new InvocationEvent(c, r));
    }
}
LWCToolkit.java 文件源码 项目:lookaside_java-1.8.0-openjdk 阅读 30 收藏 0 点赞 0 评论 0
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);
}
WEmbeddedFrame.java 文件源码 项目:lookaside_java-1.8.0-openjdk 阅读 31 收藏 0 点赞 0 评论 0
@SuppressWarnings("deprecation")
public void synthesizeWindowActivation(final boolean activate) {
    if (!activate || EventQueue.isDispatchThread()) {
        ((WFramePeer)getPeer()).emulateActivation(activate);
    } else {
        // To avoid focus concurrence b/w IE and EmbeddedFrame
        // activation is postponed by means of posting it to EDT.
        Runnable r = new Runnable() {
            public void run() {
                ((WFramePeer)getPeer()).emulateActivation(true);
            }
        };
        WToolkit.postEvent(WToolkit.targetToAppContext(this),
                           new InvocationEvent(this, r));
    }
}
WComponentPeer.java 文件源码 项目:lookaside_java-1.8.0-openjdk 阅读 25 收藏 0 点赞 0 评论 0
public void replaceSurfaceDataLater() {
    Runnable r = new Runnable() {
        @Override
        public void run() {
            // Shouldn't do anything if object is disposed in meanwhile
            // No need for sync as disposeAction in Window is performed
            // on EDT
            if (!isDisposed()) {
                try {
                    replaceSurfaceData();
                } catch (InvalidPipeException e) {
                    // REMIND : what do we do if our surface creation failed?
                }
            }
        }
    };
    Component c = (Component)target;
    // Fix 6255371.
    if (!PaintEventDispatcher.getPaintEventDispatcher().queueSurfaceDataReplacing(c, r)) {
        postEvent(new InvocationEvent(c, r));
    }
}
EventQueue.java 文件源码 项目:javify 阅读 35 收藏 0 点赞 0 评论 0
/**
 * 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);
}
EventQueue.java 文件源码 项目:jvm-stm 阅读 39 收藏 0 点赞 0 评论 0
/**
 * 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);
}
EventQueue.java 文件源码 项目:VarJ 阅读 31 收藏 0 点赞 0 评论 0
/**
    * 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);
       }
   }
LWCToolkit.java 文件源码 项目:infobip-open-jdk-8 阅读 46 收藏 0 点赞 0 评论 0
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);
}
WEmbeddedFrame.java 文件源码 项目:infobip-open-jdk-8 阅读 42 收藏 0 点赞 0 评论 0
@SuppressWarnings("deprecation")
public void synthesizeWindowActivation(final boolean activate) {
    if (!activate || EventQueue.isDispatchThread()) {
        ((WFramePeer)getPeer()).emulateActivation(activate);
    } else {
        // To avoid focus concurrence b/w IE and EmbeddedFrame
        // activation is postponed by means of posting it to EDT.
        Runnable r = new Runnable() {
            public void run() {
                ((WFramePeer)getPeer()).emulateActivation(true);
            }
        };
        WToolkit.postEvent(WToolkit.targetToAppContext(this),
                           new InvocationEvent(this, r));
    }
}
WComponentPeer.java 文件源码 项目:infobip-open-jdk-8 阅读 27 收藏 0 点赞 0 评论 0
public void replaceSurfaceDataLater() {
    Runnable r = new Runnable() {
        @Override
        public void run() {
            // Shouldn't do anything if object is disposed in meanwhile
            // No need for sync as disposeAction in Window is performed
            // on EDT
            if (!isDisposed()) {
                try {
                    replaceSurfaceData();
                } catch (InvalidPipeException e) {
                    // REMIND : what do we do if our surface creation failed?
                }
            }
        }
    };
    Component c = (Component)target;
    // Fix 6255371.
    if (!PaintEventDispatcher.getPaintEventDispatcher().queueSurfaceDataReplacing(c, r)) {
        postEvent(new InvocationEvent(c, r));
    }
}
LWCToolkit.java 文件源码 项目:jdk8u-dev-jdk 阅读 34 收藏 0 点赞 0 评论 0
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);
}
WEmbeddedFrame.java 文件源码 项目:jdk8u-dev-jdk 阅读 37 收藏 0 点赞 0 评论 0
@SuppressWarnings("deprecation")
public void synthesizeWindowActivation(final boolean activate) {
    if (!activate || EventQueue.isDispatchThread()) {
        ((WFramePeer)getPeer()).emulateActivation(activate);
    } else {
        // To avoid focus concurrence b/w IE and EmbeddedFrame
        // activation is postponed by means of posting it to EDT.
        Runnable r = new Runnable() {
            public void run() {
                ((WFramePeer)getPeer()).emulateActivation(true);
            }
        };
        WToolkit.postEvent(WToolkit.targetToAppContext(this),
                           new InvocationEvent(this, r));
    }
}
WComponentPeer.java 文件源码 项目:jdk8u-dev-jdk 阅读 30 收藏 0 点赞 0 评论 0
public void replaceSurfaceDataLater() {
    Runnable r = new Runnable() {
        @Override
        public void run() {
            // Shouldn't do anything if object is disposed in meanwhile
            // No need for sync as disposeAction in Window is performed
            // on EDT
            if (!isDisposed()) {
                try {
                    replaceSurfaceData();
                } catch (InvalidPipeException e) {
                    // REMIND : what do we do if our surface creation failed?
                }
            }
        }
    };
    Component c = (Component)target;
    // Fix 6255371.
    if (!PaintEventDispatcher.getPaintEventDispatcher().queueSurfaceDataReplacing(c, r)) {
        postEvent(new InvocationEvent(c, r));
    }
}
WComponentPeer.java 文件源码 项目:jdk7-jdk 阅读 25 收藏 0 点赞 0 评论 0
public void replaceSurfaceDataLater() {
    Runnable r = new Runnable() {
        public void run() {
            // Shouldn't do anything if object is disposed in meanwhile
            // No need for sync as disposeAction in Window is performed
            // on EDT
            if (!isDisposed()) {
                try {
                    replaceSurfaceData();
                } catch (InvalidPipeException e) {
                // REMIND : what do we do if our surface creation failed?
                }
            }
        }
    };
    // Fix 6255371.
    if (!PaintEventDispatcher.getPaintEventDispatcher().queueSurfaceDataReplacing((Component)target, r)) {
        postEvent(new InvocationEvent(Toolkit.getDefaultToolkit(), r));
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号