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.
Constructors
Initializes a new instance of EventQueue
.
Creates a new secondary loop
associated with this event queue.
protected void
Returns the event currently being dispatched by the EventQueue
associated with the calling thread.
static long
Returns the timestamp of the most recent event that had a timestamp, and that was dispatched from the EventQueue
associated with the calling thread.
Removes an event from the EventQueue
and returns it.
static void
static void
static boolean
Returns the first event on the EventQueue
without removing it.
Returns the first event with the specified id, if any.
protected void
Stops dispatching events using this EventQueue
.
void
Posts a 1.1-style event to the EventQueue
.
void
Replaces the existing EventQueue
with the specified one.
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public EventQueue()
Initializes a new instance of EventQueue
.
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.
theEvent
- an instance of java.awt.AWTEvent
, or a subclass of it
NullPointerException
- if theEvent
is null
Removes an event from the EventQueue
and returns it. This method will block until an event has been posted by another thread.
AWTEvent
InterruptedException
- if any thread has interrupted this thread
Returns the first event on the EventQueue
without removing it.
Returns the first event with the specified id, if any.
id
- the id of the type of event desired
null
if there is no such event
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:
Event types, source types, and dispatch methods Event Type Source Type Dispatched To ActiveEvent Any event.dispatch() Other Component source.dispatchEvent(AWTEvent) Other MenuComponent source.dispatchEvent(AWTEvent) Other Other No action (ignored)event
- an instance of java.awt.AWTEvent
, or a subclass of it
NullPointerException
- if event
is null
public static long getMostRecentEventTime()
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
InputEvent
s,
ActionEvent
s, and
InvocationEvent
s 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.
InputEvent
, ActionEvent
, or InvocationEvent
to be dispatched, or System.currentTimeMillis()
if this method is invoked on a thread other than an event dispatching thread
()
Returns 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.
Replaces the existing EventQueue
with the specified one. Any pending events are transferred to the new EventQueue
for processing by it.
newEventQueue
- an EventQueue
(or subclass thereof) instance to be use
NullPointerException
- if newEventQueue
is null
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.
EmptyStackException
- if no previous push was made on this EventQueue
public static boolean isDispatchThread()
the current AWT EventQueue
's dispatch thread
runnable
- the Runnable
whose run
method should be executed asynchronously in the event dispatch thread
of the system EventQueue
runnable
- the Runnable
whose run
method should be executed synchronously in the event dispatch thread
of the system EventQueue
InterruptedException
- if any thread has interrupted this thread
InvocationTargetException
- if an throwable is thrown when running runnable
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4