public interface StateMachineListener
The listener interface for receiving events fired by state machines. (An event is fired
by a state machine when its method fireEvent
has been called).
The class that is interested in processing events fired by a state machine implements this interface (and the method it contains).
The listener object created from that class is then registered with a state machine sm
using
the addStateMachineListener
method on sm
.
The following example is just an illustration of the mechanism and is not very useful.
Note that a state machine is itself a StateMachineListener
so a
state machine can process events fired by other state machine. To see a more
interesting example that uses two state machines, take a look at the pie menu applet example on
SwingStates web site.
CStateMachine sm = new CStateMachine() { public State start = new State() { Transition selectColor = new PressOnShape() { public void action() { fireEvent(new VirtualEvent(""+getShape().getFillPaint())); } }; }; }; sm.addStateMachineListener(new StateMachineListener() { public void eventOccured(EventObject event) { System.out.println("The pressed shape is filled in "+((VirtualEvent)event).getName()); }; });
StateMachineEvent
,
StateMachineEventAdapter
Modifier and Type | Method and Description |
---|---|
void |
eventOccured(java.util.EventObject eventObject)
Invoked when the state machine has fired an event.
|