java.awt
Class EventQueue
java.lang.Object
|
+--java.awt.EventQueue
public class
EventQueueextends
Object This class manages a queue of AWTEvent
objects that
are posted to it. The AWT system uses only one event queue for all
events.
Authors:- Bryce McKinlay
- Aaron M. Renn (arenn@urbanophile.com)
EventQueue
public EventQueue()
Initializes a new instance of EventQueue
.
dispatchEvent
protected void dispatchEvent(java.awt.AWTEvent evt)
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.
Parameters:
Throws:
getMostRecentEventTime
public static long getMostRecentEventTime()
Returns the timestamp of the most recent event that had a timestamp, or
the initialization time of the event queue if no events have been fired.
At present, only InputEvent
s, ActionEvent
s,
InputMethodEvent
s, and InvocationEvent
s have
timestamps, but this may be added to other events in future versions.
If this is called by the event dispatching thread, it can be any
(sequential) value, but to other threads, the safest bet is to return
System.currentTimeMillis().
Since:Returns:
- the most recent timestamp
See Also:
getNextEvent
public synchronized AWTEvent getNextEvent()
Returns the next event in the queue. This method will block until
an event is available or until the thread is interrupted.
Returns:
- The next event in the queue.
Throws:
InterruptedException
- If this thread is interrupted while
waiting for an event to be posted to the queue.
invokeAndWait
public static void invokeAndWait(java.lang.Runnable runnable)
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.
Since:Parameters:
Throws:
invokeLater
public static void invokeLater(java.lang.Runnable runnable)
Since:Parameters:
isDispatchThread
public static boolean isDispatchThread()
peekEvent
public synchronized AWTEvent peekEvent()
Returns the next event in the queue without removing it from the queue.
This method will block until an event is available or until the thread
is interrupted.
Returns:
- The next event in the queue.
peekEvent
public synchronized AWTEvent peekEvent(int id)
Returns the next event in the queue that has the specified id
without removing it from the queue.
This method will block until an event is available or until the thread
is interrupted.
Parameters:
Returns:
- The next event in the queue.
pop
protected void pop()
Transfer any pending events from this queue back to the parent queue that
was previously push()ed. Event dispatch from this queue is suspended.
Throws:
postEvent
public synchronized void postEvent(java.awt.AWTEvent evt)
Posts a new event to the queue.
Parameters:
Throws:
push
public synchronized void push(java.awt.EventQueue newEventQueue)
Allows a custom EventQueue implementation to replace this one.
All pending events are transferred to the new queue. Calls to postEvent,
getNextEvent, and peekEvent are forwarded to the pushed queue until it
is removed with a pop().
Parameters:
Throws:
AWTEvent
objects that are posted to it. The AWT system uses only one event queue for all events.