charva.awt

Class EventQueue


public class EventQueue
extends java.lang.Object

The EventQueue class queues "AWT" events, which are used to trigger drawing actions. They can be enqueued using the postEvent() method by any thread (e.g the keyboard reading thread enqueues KeyEvents), but only the event-dispatching thread should call getNextEvent(), because only the event-dispatching thread should do any drawing. This is because the ncurses library is not re-entrant.

SyncEvents are enqueued with a lower priority than other events, and if multiple SyncEvents are found on the queue they are coalesced into a single SyncEvent.

Method Summary

static EventQueue
getInstance()
AWTEvent
getNextEvent()
This method is only called if we know that an event is available.
static void
invokeLater(Runnable runnable_)
Causes the runnable's run() method to be called in the AWT dispatch thread.
void
postEvent(AWTEvent evt_)
boolean
queuesAreEmpty()
Returns true if both the high-priority queue and the low-priority queue are empty.
AWTEvent
waitForNextEvent()
Block until an event is available, then return the event.

Method Details

getInstance

public static EventQueue getInstance()

getNextEvent

public AWTEvent getNextEvent()
This method is only called if we know that an event is available.
Returns:
the first AWTEvent on the queue.

invokeLater

public static void invokeLater(Runnable runnable_)
Causes the runnable's run() method to be called in the AWT dispatch thread.

postEvent

public void postEvent(AWTEvent evt_)

queuesAreEmpty

public boolean queuesAreEmpty()
Returns true if both the high-priority queue and the low-priority queue are empty. It is not necessary to make this synchronized because it is called from a synchronized method.

waitForNextEvent

public AWTEvent waitForNextEvent()
Block until an event is available, then return the event.
Returns:
the AWTEvent