| public class java.awt EventQueue
|
Java SE 6 |
EventQueue is a platform-independent class
that queues events, both from the underlying peer classes
and from trusted application classes.
It encapsulates asynchronous event dispatch machinery which
extracts events from the queue and dispatches them by calling
dispatchEvent(AWTEvent) method
on this EventQueue with the event to be dispatched
as an argument. The particular behavior of this machinery is
implementation-dependent. The only requirements are that events
which were actually enqueued to this queue (note that events
being posted to the EventQueue can be coalesced)
are dispatched:
AWTEvent A is enqueued
to the EventQueue before
AWTEvent B then event B will not be
dispatched before event A.
Some browsers partition applets in different code bases into
separate contexts, and establish walls between these contexts.
In such a scenario, there will be one EventQueue
per context. Other browsers place all applets into the same
context, implying that there will be only a single, global
EventQueue for all applets. This behavior is
implementation-dependent. Consult your browser's documentation
for more information.
For information on the threading issues of the event dispatch machinery, see AWT Threading Issues.
| version | 1.105, 07/11/06 |
| since | 1.1 |
| Constructors | |
|---|---|
| public | EventQueue() |
| Methods | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| protected void | dispatchEvent(AWTEvent event) Details
Dispatches an event. The manner in which the event is
dispatched depends upon the type of the event and the
type of the event's source object:
| |||||||||||||||||||||
| public static void | invokeAndWait(Runnable runnable) throws InterruptedException, InvocationTargetException Details
Causes runnable to have its run
method called in the dispatch thread of
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.
| |||||||||||||||||||||
| public static void | invokeLater(Runnable runnable) Details
Causes runnable to have its run
method called in the dispatch thread of
the system EventQueue.
This will happen after all pending events are processed.
| |||||||||||||||||||||
| public AWTEvent | peekEvent() Details
Returns the first event on the EventQueue
without removing it.
| |||||||||||||||||||||
| public AWTEvent | peekEvent(int id) Details
Returns the first event with the specified id, if any.
| |||||||||||||||||||||
| protected void | pop() throws EmptyStackException Details
Stops dispatching events using this EventQueue.
Any pending events are transferred to the previous
EventQueue for processing.
Warning: To avoid deadlock, do not declare this method synchronized in a subclass.
| |||||||||||||||||||||
| public void | postEvent(AWTEvent theEvent) Details
Posts a 1.1-style event to the EventQueue.
If there is an existing event on the queue with the same ID
and event source, the source Component's
coalesceEvents method will be called.
| |||||||||||||||||||||
| public void | push(EventQueue newEventQueue) Details
Replaces the existing EventQueue with the specified one.
Any pending events are transferred to the new EventQueue
for processing by it.
| |||||||||||||||||||||
| Properties | |||||||
|---|---|---|---|---|---|---|---|
| public static AWTEvent | getCurrentEvent() Details
Returns the the event currently being dispatched by the
EventQueue associated with the calling thread. This is
useful if a method needs access to the event, but was not designed to
receive a reference to it as an argument. Note that this method should
only be invoked from an application's event dispatching thread. If this
method is invoked from another thread, null will be returned.
| ||||||
| public static boolean | isDispatchThread() Details
Returns true if the calling thread is the current AWT
EventQueue's dispatch thread. Use this
call the ensure that a given
task is being executed (or not being) on the current AWT
EventDispatchThread.
| ||||||
| public static long | getMostRecentEventTime() Details
Returns the timestamp of the most recent event that had a timestamp, and
that was dispatched from the EventQueue associated with the
calling thread. If an event with a timestamp is currently being
dispatched, its timestamp will be returned. If no events have yet
been dispatched, the EventQueue's initialization time will be
returned instead.In the current version of
the JDK, only InputEvents,
ActionEvents, and InvocationEvents have
timestamps; however, future versions of the JDK may add timestamps to
additional event types. Note that this method should only be invoked
from an application's event dispatching thread. If this method is
invoked from another thread, the current system time (as reported by
System.currentTimeMillis()) will be returned instead.
| ||||||
| public AWTEvent | getNextEvent() throws InterruptedException Details
Removes an event from the EventQueue and
returns it. This method will block until an event has
been posted by another thread.
| ||||||
| About DocWeb · Bundles · Export · Export All | Top 10 · Statistics · Login |
| About Sun · Contact · Privacy · Terms of Use · Trademarks | Java SE 6 · Copyright © 1994-2013 Sun Microsystems, Inc.All rights reserved. Use is subject to license terms |
![]() |
![]() |
|