|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.swing.Timer
org.jscience.swing.spinner.SharableTimer
public class SharableTimer
This Timer is optimized for sharable usage from different contexts, for example: Two Objects want to share one Timer. (This is similar to a Model-View-Architecture.)
To start this timer, the starting context must call one of the following methods: and give this Timer the delay, the coalesce state and all relevantActionListeners listening to this Timer.
Before beginning to send ActionEvents to the Listeners,
this Timer will add the specified ActionListeners.
A call to stop() will remove these added ActionListeners.
Of course, all other ActionListeners which were added by the
inherited method Timer.addActionListener(ActionListener)
wont be removed.
Further more this Timer fires a ChangeEvent to all added
ChangeListeners whenever it has been started or stopped.
As an example you can check up both Joggle and
TimerControlPanel.
| Field Summary | |
|---|---|
protected javax.swing.event.EventListenerList |
changeListenerList
|
| Fields inherited from class javax.swing.Timer |
|---|
listenerList |
| Constructor Summary | |
|---|---|
SharableTimer()
Creates a new SharableTimer with a delay of 0 and no ActionListener. |
|
| Method Summary | |
|---|---|
void |
addChangeListener(javax.swing.event.ChangeListener l)
Adds a listener to the list that is notified each time this Timer will be started or stopped. |
protected void |
fireStateChanged()
Sends a ChangeEvent, whose source is this Timer, to each ChangeListener which was added to this Timer. |
void |
removeChangeListener(javax.swing.event.ChangeListener l)
Removes a ChangeListener from this Timer. |
void |
start()
Does nothing - please use one of the other start methods to start this Timer. |
void |
start(int delay,
java.awt.event.ActionListener[] listenerToAdd,
boolean coalesce)
Adds all listenerToAdd, starts this Timer and calls
fireStateChanged(). |
void |
start(int delay,
java.awt.event.ActionListener listenerToAdd,
boolean coalesce)
Similar to start(int,ActionListener[],boolean), but expecting
only one ActionListener to add. |
void |
stop()
Stops this Timer, removes the added ActionListeners recently given to one of the start-methods and calls fireStateChanged(). |
| Methods inherited from class javax.swing.Timer |
|---|
addActionListener, fireActionPerformed, getActionCommand, getActionListeners, getDelay, getInitialDelay, getListeners, getLogTimers, isCoalesce, isRepeats, isRunning, removeActionListener, restart, setActionCommand, setCoalesce, setDelay, setInitialDelay, setLogTimers, setRepeats |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected javax.swing.event.EventListenerList changeListenerList
| Constructor Detail |
|---|
public SharableTimer()
| Method Detail |
|---|
public void start(int delay,
java.awt.event.ActionListener[] listenerToAdd,
boolean coalesce)
listenerToAdd, starts this Timer and calls
fireStateChanged().
If this timer is already running it will previously be stopped
and starts running with the new parameters - in other words:
this Timer will be restarted.
delay - the timer delay.listenerToAdd - all ActionListeners to add before starting this timer.coalesce - the coalesce state this Timer should work with.Timer.setDelay(int),
Timer.setCoalesce(boolean),
Timer.addActionListener(ActionListener)
public void start(int delay,
java.awt.event.ActionListener listenerToAdd,
boolean coalesce)
start(int,ActionListener[],boolean), but expecting
only one ActionListener to add.
delay - the timer delay.listenerToAdd - an ActionListener to add before starting this timer.coalesce - the coalesce state this Timer should work with.public void start()
start in class javax.swing.Timerstart(int,ActionListener[],boolean),
start(int,ActionListener,boolean)public void stop()
fireStateChanged().
If this Timer is already stopped, this method does nothing.
stop in class javax.swing.Timerpublic void addChangeListener(javax.swing.event.ChangeListener l)
l - the ChangeListener to addpublic void removeChangeListener(javax.swing.event.ChangeListener l)
l - the listener to remove.protected void fireStateChanged()
#addChangeListener(ChangeListenerl)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||