Package com.sun.speech.engine

# Class SpeechEventUtilities

java.lang.Object
com.sun.speech.engine.SpeechEventUtilities

public class SpeechEventUtilities extends Object
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 Classes
Modifier and Type
Class
Description
`protected static class`
`SpeechEventUtilities.SpeechAWTEvent`
Inner class that defines SpeechAWTEvents.
`protected static class`
`SpeechEventUtilities.SpeechAWTEventTarget`
Inner class used to handle events as they are dispatched from the AWT event queue.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected static boolean`
`awtRunning`
If true, the AWT EventQueue has been set up in the VM.
`protected static SpeechEventUtilities.SpeechAWTEventTarget`
`speechAWTEventTarget`
A target used to process speechAWTEvent objects.
`protected static EventQueue`
`systemEventQueue`
The AWT EventQueue.
`static boolean`
`waitUntilDispatched`
If true, wait until an event has been dispatched before returning from the post method.

## Constructor Summary

Constructors
Constructor
Description
`SpeechEventUtilities()`

## Method Summary

Modifier and Type
Method
Description
`protected static boolean`
`isAWTRunning()`
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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### awtRunning

protected static boolean awtRunning
If 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

protected static EventQueue systemEventQueue
The AWT EventQueue. This is lazily created in postSpeechEvent to delay the need to initialize the Toolkit until it is necessary.

See Also:
  - `postSpeechEvent(com.sun.speech.engine.SpeechEventDispatcher, SpeechEvent)`

### speechAWTEventTarget

protected static SpeechEventUtilities.SpeechAWTEventTarget 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.

See Also:
  - `postSpeechEvent(com.sun.speech.engine.SpeechEventDispatcher, SpeechEvent)`

### waitUntilDispatched

public static boolean waitUntilDispatched
If 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.

See Also:
  - `postSpeechEvent(com.sun.speech.engine.SpeechEventDispatcher, SpeechEvent)`

## 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

public static void postSpeechEvent(SpeechEventDispatcher dispatcher, SpeechEvent event)
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 event
  `event` - 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 event
  `event` - the SpeechEvent to post
  `waitUntilDispatched` - if true, do not return until the event have been dispatched