Package com.sun.speech.engine
Class SpeechEventUtilities
java.lang.Object
com.sun.speech.engine.SpeechEventUtilities
Utilities to help with dispatch JSAPI 1.0 events on the event
dispatching thread of AWT/Swing. This is needed to help
applications conform with the Swing Event Thread model. If these
utilities were not used, then a GUI application would have to
implement Runnables to handle JSAPI events that result in updates
to the GUI.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
Inner class that defines SpeechAWTEvents.protected static class
Inner class used to handle events as they are dispatched from the AWT event queue. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static boolean
If true, the AWT EventQueue has been set up in the VM.protected static SpeechEventUtilities.SpeechAWTEventTarget
A target used to process speechAWTEvent objects.protected static EventQueue
The AWT EventQueue.static boolean
If true, wait until an event has been dispatched before returning from the post method. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static boolean
Determine if the AWT event queue is running.static void
postSpeechEvent
(SpeechEventDispatcher dispatcher, SpeechEvent event) Post a JSAPI SpeechEvent.static void
postSpeechEvent
(SpeechEventDispatcher dispatcher, SpeechEvent event, boolean waitUntilDispatched) Post a JSAPI SpeechEvent.
-
Field Details
-
awtRunning
protected static boolean awtRunningIf true, the AWT EventQueue has been set up in the VM. This flag is used to determine whether we should use the AWT EventQueue for synchronizing SpeechEvents with the AWT EventQueue or not. -
systemEventQueue
The AWT EventQueue. This is lazily created in postSpeechEvent to delay the need to initialize the Toolkit until it is necessary. -
speechAWTEventTarget
A target used to process speechAWTEvent objects. This target is a component that expresses interest in SpeechAWTEvents. It is lazily created along with systemEventQueue in postSpeechEvent. -
waitUntilDispatched
public static boolean waitUntilDispatchedIf true, wait until an event has been dispatched before returning from the post method. This is meant to be a global debugging flag. If a class calling postSpeechEvent wants to wait until the SpeechEvent has been dispatched, it should call the postSpeechEvent method that has the waitUntilDispatched parameter.
-
-
Constructor Details
-
SpeechEventUtilities
public SpeechEventUtilities()
-
-
Method Details
-
isAWTRunning
protected static boolean isAWTRunning()Determine if the AWT event queue is running. This method is one big hack, and we will be entering a bug against AWT to provide us with a real method for determining if AWT is active or not. The problem with asking AWT if it is active right now is that it will activate it if it isn't already active. -
postSpeechEvent
Post a JSAPI SpeechEvent. This is to be used by multiple processes to synchronize SpeechEvents. It currently uses the AWT EventQueue as a means for doing this, which has the added benefit of causing all SpeechEvent notification to be done from the event dispatch thread. This is important because the Swing Thread Model requires all interaction with Swing components to be done from the event dispatch thread. This method will immediately return once the event has been posted if the global waitUntilDispatched flag is set to false. Otherwise, it will wait until the event has been dispatched before returning.- Parameters:
dispatcher
- the dispatcher that will dispatch the eventevent
- the SpeechEvent to post
-
postSpeechEvent
public static void postSpeechEvent(SpeechEventDispatcher dispatcher, SpeechEvent event, boolean waitUntilDispatched) Post a JSAPI SpeechEvent. This is to be used by multiple processes to synchronize SpeechEvents. It currently uses the AWT EventQueue as a means for doing this, which has the added benefit of causing all SpeechEvent notification to be done from the event dispatch thread. This is important because the Swing Thread Model requires all interaction with Swing components to be done from the event dispatch thread. This method will immediately return once the event has been posted if the waitUntilDispatched parameter is set to false. Otherwise, it will wait until the event has been dispatched before returning.- Parameters:
dispatcher
- the dispatcher that will dispatch the eventevent
- the SpeechEvent to postwaitUntilDispatched
- if true, do not return until the event have been dispatched
-