Package com.nomagic.ui
Class EventQueueDispatcher
java.lang.Object
com.nomagic.ui.EventQueueDispatcher
AWT event dispatcher which dispatches events in the event queue thread until done condition is encountered.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates aEventQueueDispatcherand resets done condition. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancustomDispatchMouseEvent(com.nomagic.ui.EventQueueDispatcher.Dispatcher dispatcher, EventQueue eventQueue, MouseEvent mouseEvent) protected voidDispatches AWT events until done condition is encountered.protected booleandispatchEvents(int timeout) Dispatches AWT events until done condition is encountered or timeout is reached whatever happens first.static voidThis is required to avoid hang.voidSets done condition which causesdispatchEventsmethod to exit.voidForcefully sets timeout condition which causesdispatchEventsmethod to exit.protected booleanThe method has to be called from event thread.protected voidreset()Resets done condition.final voidsetDispatchTheseEvents(Predicate<AWTEvent> dispatchTheseEvents) Set verification which events needs to be dispatched.
-
Constructor Details
-
EventQueueDispatcher
protected EventQueueDispatcher()Creates aEventQueueDispatcherand resets done condition.
-
-
Method Details
-
reset
protected void reset()Resets done condition.The method has to be called from event thread.
-
dispatchEvents
protected void dispatchEvents()Dispatches AWT events until done condition is encountered.The method has to be called from event thread.
-
dispatchEvents
protected boolean dispatchEvents(int timeout) Dispatches AWT events until done condition is encountered or timeout is reached whatever happens first.The method has to be called from event thread.
- Parameters:
timeout- the timeout or -1 if there is no timeout- Returns:
trueif dispatching has stopped because of done condition,falseif dispatching has stopped because timeout was reached.
-
disposeSequencedEvent
public static void disposeSequencedEvent()This is required to avoid hang. -
doneDispatching
public void doneDispatching()Sets done condition which causesdispatchEventsmethod to exit. -
forceTimeout
public void forceTimeout()Forcefully sets timeout condition which causesdispatchEventsmethod to exit. -
isDoneDispatching
protected boolean isDoneDispatching()The method has to be called from event thread.
- Returns:
trueif done condition was encountered.
-
customDispatchMouseEvent
protected boolean customDispatchMouseEvent(com.nomagic.ui.EventQueueDispatcher.Dispatcher dispatcher, EventQueue eventQueue, MouseEvent mouseEvent) -
setDispatchTheseEvents
Set verification which events needs to be dispatched. For normal UI only invocation events are dispatched.- Parameters:
dispatchTheseEvents- predicate to check if event needs to be dispatched
-
getDispatchTheseEvents
-