public class SIMPluginAWTEventDispatcher
extends java.lang.Object
getDispatcher()
method to register listeners for the events.
Then, the startThread() method must be called to start the thread that sends the events to the listeners.
For example:
//create a SIMPlugin to the SIM and pass it to the createDispatcher(). SIMPluginAWTEventDispatcher.createDispatcher( SIMPlugin.createSIMPlugin(m_SIM) ); //process SIMPlugin arguments. SIMPluginAWTEventDispatcher.getDispatcher().getSIMPlugin().setPlay(m_play); //initialize your application, register all the listeners m_geardata = new JDataLabel("Car/REFERENCE/Gauge/Gear/ValueCurrent"); m_geardata.addPropertyChangeListener("data", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { Data d = (Data) evt.getNewValue(); // normally you would do some fancy formatting that the // setFormat() method cannot handle. m_geardata.setText("[" + d.getString() + "]"); } }); widgetPanel.add(m_geardata); //start the dispatcher thread running to place data into the event queue SIMPluginAWTEventDispatcher.getDispatcher().startThread();
Modifier and Type | Class and Description |
---|---|
class |
SIMPluginAWTEventDispatcher.SIMPluginAWTEventsException
Any exceptions are caught and wrapped in this exception.
|
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Since I cannot listen unless you give me the name, this method throws an exception.
|
void |
addPropertyChangeListener(java.lang.String name,
java.beans.PropertyChangeListener listener)
Registers a listener to receive events for the named SIM value.
|
static SIMPluginAWTEventDispatcher |
createDispatcher(SIMPlugin SIMPlugin)
A static factory method that creates the dispatcher instance and returns it.
|
static SIMPluginAWTEventDispatcher |
getDispatcher()
Returns the dispatcher singleton.
|
SIMPlugin |
getSIMPlugin()
Returns the SIMPlugin.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Since I cannot listen unless you give me the name, this method throws an exception.
|
void |
removePropertyChangeListener(java.lang.String name,
java.beans.PropertyChangeListener listener)
Removes a listener that was already registered to receive events for the named SIM value.
|
void |
startThread() |
void |
startThread(SIMPlugin.Callback callback)
Starts the dispatcher thread.
|
public static SIMPluginAWTEventDispatcher createDispatcher(SIMPlugin SIMPlugin)
SIMPlugin
- The SIMPlugin.public static SIMPluginAWTEventDispatcher getDispatcher()
public SIMPlugin getSIMPlugin()
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener) throws SIMPluginAWTEventDispatcher.SIMPluginAWTEventsException
listener
- The listener to receive the events.SIMPluginAWTEventDispatcher.SIMPluginAWTEventsException
- A fatal exception.public void removePropertyChangeListener(java.beans.PropertyChangeListener listener) throws SIMPluginAWTEventDispatcher.SIMPluginAWTEventsException
listener
- The listener to receive the events.SIMPluginAWTEventDispatcher.SIMPluginAWTEventsException
- A fatal exception.public void addPropertyChangeListener(java.lang.String name, java.beans.PropertyChangeListener listener)
name
- The name of the value.listener
- The listener to receive the events.public void removePropertyChangeListener(java.lang.String name, java.beans.PropertyChangeListener listener)
name
- The name of the value.listener
- The listener to receive the events.public void startThread(SIMPlugin.Callback callback)
callback
- (Optional) A callback implementation to receive events.public void startThread()