Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.awt

Class EventQueue

java.lang.Object
|
+--java.awt.EventQueue


public class EventQueue

extends 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:

Constructor Summary

EventQueue()

Initializes a new instance of EventQueue.

Method Summary

voiddispatchEvent(java.awt.AWTEvent evt)

Dispatches an event.
static longgetMostRecentEventTime()

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.
synchronized java.awt.AWTEventgetNextEvent()

Returns the next event in the queue.
static voidinvokeAndWait(java.lang.Runnable runnable)

Causes runnable to have its run method called in the dispatch thread of the EventQueue.
static voidinvokeLater(java.lang.Runnable runnable)

static booleanisDispatchThread()

synchronized java.awt.AWTEventpeekEvent()

Returns the next event in the queue without removing it from the queue.
synchronized java.awt.AWTEventpeekEvent(int id)

Returns the next event in the queue that has the specified id without removing it from the queue.
voidpop()

Transfer any pending events from this queue back to the parent queue that was previously push()ed.
synchronized voidpostEvent(java.awt.AWTEvent evt)

Posts a new event to the queue.
synchronized voidpush(java.awt.EventQueue newEventQueue)

Allows a custom EventQueue implementation to replace this one.

Constructor Details

EventQueue

public EventQueue()

Initializes a new instance of EventQueue.


Method Details

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 InputEvents, ActionEvents, InputMethodEvents, and InvocationEvents 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:

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:

Throws:


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:


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:


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: