|
|||||||||
| Home >> All >> [ echopoint overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
echopoint
Class Timer

java.lang.Objectnextapp.echo.Component
echopoint.Timer
- All Implemented Interfaces:
- echopoint.util.reflect.ReflectionSetter, java.io.Serializable
- public class Timer
- extends nextapp.echo.Component
- implements echopoint.util.reflect.ReflectionSetter
- extends nextapp.echo.Component
The Timer class is a Component
that causes an action to occur at a predefined rate.
Each Timer has a list of ActionListeners and a
delay ( the time between actionPerfomed() calls).
When delay milliseconds have passed, a Timer sends the
actionPerformed() message to its listeners.
This cycle repeats until stop() is called, or
halts immediately if the Timer is configured to
send its message just once.
Note that this is a very coarse timer. The timer is run on the
client and the timeout must travel back to the server before any
other code can be notified of this event. Therefore the granuality
of the timer cannot be gaurunteed, as it depends on the client speed and
the network speed between the client and server.
This class is mostly useful for causing the client to update without having
to have the user click on anything.
You can only have one effective Timer on a Window at a time.
This is because once the lowest delay timer has popped, any screen updates
will cause all Timers on that Window to be reset to their
respective starting delays, regardless of how much time has passed since the
last event happened on a given timer.
The reason the Timer is fired on the client rather than via a thread on the server,
is to help support many clients (thousands). Each client is running their
own timers, using their own processing power. If a single thread was created for
all Timers (or worse one per client) then the system would eventually grind to a halt.
| Field Summary | |
private java.lang.String |
actionCommand
|
private int |
delay
|
private boolean |
hasFired
|
private int |
initialDelay
|
private boolean |
repeats
|
private boolean |
running
|
static java.lang.String |
TIMER_CHANGED_PROPERTY
|
| Constructor Summary | |
Timer()
Creates a Timer that will notify its
listeners every 1000 milliseconds. |
|
Timer(int delay)
Creates a Timer that will notify its
listeners every delay milliseconds. |
|
Timer(int delay,
nextapp.echo.event.ActionListener actionListener)
Creates a Timer that will notify its
listeners every delay milliseconds. |
|
| Method Summary | |
void |
addActionListener(nextapp.echo.event.ActionListener l)
Adds an ActionListener to the Timer. |
void |
fireActionPerformed(nextapp.echo.event.ActionEvent e)
Notifies all listeners that have registered for this event type. |
java.lang.String |
getActionCommand()
|
int |
getDelay()
|
int |
getInitialDelay()
|
boolean |
hasFired()
|
boolean |
isRepeats()
Returns true if the Timer will send a
actionPerformed() message to its listeners
multiple times. |
boolean |
isRunning()
|
void |
removeActionListener(nextapp.echo.event.ActionListener l)
Removes an ActionListener from the Timer. |
void |
restart()
Restarts a Timer, canceling any pending firings, and causing
it to fire with its initial dely. |
java.lang.Object |
set(java.lang.reflect.Field field,
java.lang.Object newValue)
Called to save the old value of a field, set in a new value and return the old value of a field. |
void |
setActionCommand(java.lang.String newValue)
Sets the Timer's action command. |
void |
setDelay(int newValue)
Sets the Timer's delay, the number of
milliseconds between successive actionPerfomed()
messages to its listeners
This methods fires a PropertyChangeEvent with a
getPropertyName() value of
Timer.TIMER_CHANGED_PROPERTY |
void |
setInitialDelay(int newValue)
Sets the Timer's initial delay. |
void |
setRepeats(boolean newValue)
Instructs the Timer to send actionPerformed()
to its listeners only once, and then stop. |
void |
start()
Starts the Timer, causing it to send actionPerformed()
messages to its listeners. |
void |
stop()
Stops the Timer, causing it to stop sending actionPerformed()
messages to its listeners. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
TIMER_CHANGED_PROPERTY
public static final java.lang.String TIMER_CHANGED_PROPERTY
- See Also:
- Constant Field Values
actionCommand
private java.lang.String actionCommand
delay
private int delay
hasFired
private boolean hasFired
initialDelay
private int initialDelay
repeats
private boolean repeats
running
private boolean running
| Constructor Detail |
Timer
public Timer()
- Creates a
Timerthat will notify its listeners every1000milliseconds.
Timer
public Timer(int delay)
- Creates a
Timerthat will notify its listeners everydelaymilliseconds.
Timer
public Timer(int delay,
nextapp.echo.event.ActionListener actionListener)
- Creates a
Timerthat will notify its listeners everydelaymilliseconds.
| Method Detail |
addActionListener
public void addActionListener(nextapp.echo.event.ActionListener l)
- Adds an
ActionListenerto the Timer.
fireActionPerformed
public void fireActionPerformed(nextapp.echo.event.ActionEvent e)
- Notifies all listeners that have registered for this event type.
getActionCommand
public java.lang.String getActionCommand()
getDelay
public int getDelay()
getInitialDelay
public int getInitialDelay()
hasFired
public boolean hasFired()
isRepeats
public boolean isRepeats()
- Returns true if the
Timerwill send aactionPerformed()message to its listeners multiple times.
isRunning
public boolean isRunning()
removeActionListener
public void removeActionListener(nextapp.echo.event.ActionListener l)
- Removes an
ActionListenerfrom the Timer.
restart
public void restart()
- Restarts a
Timer, canceling any pending firings, and causing it to fire with its initial dely.
setActionCommand
public void setActionCommand(java.lang.String newValue)
- Sets the Timer's action command.
setDelay
public void setDelay(int newValue)
- Sets the
Timer'sdelay, the number of milliseconds between successiveactionPerfomed()messages to its listeners
This methods fires aPropertyChangeEventwith agetPropertyName()value ofTimer.TIMER_CHANGED_PROPERTY
setInitialDelay
public void setInitialDelay(int newValue)
- Sets the
Timer'sinitial delay. This will be used for the first "ringing" of the Timer only. Subsequent ringings will be spaced using the delay property.
This methods fires aPropertyChangeEventwith agetPropertyName()value ofTimer.TIMER_CHANGED_PROPERTY
setRepeats
public void setRepeats(boolean newValue)
- Instructs the
Timerto sendactionPerformed()to its listeners only once, and then stop.
This methods fires aPropertyChangeEventwith agetPropertyName()value ofTimer.TIMER_CHANGED_PROPERTY
start
public void start()
- Starts the
Timer, causing it to sendactionPerformed()messages to its listeners.
stop
public void stop()
- Stops the
Timer, causing it to stop sendingactionPerformed()messages to its listeners.
set
public java.lang.Object set(java.lang.reflect.Field field, java.lang.Object newValue) throws java.lang.Exception
- Description copied from interface:
echopoint.util.reflect.ReflectionSetter - Called to save the old value of a field, set in a new value
and return the old value of a field. This interface allows
a field set operation to be "delegated" back into the class
that has permission to perform the field set.
public Object set(Field f, Object newValue) throws Exception { Object oldValue = f.get(this); f.set(this,newValue); return oldValue; }- Specified by:
setin interfaceechopoint.util.reflect.ReflectionSetter
|
|||||||||
| Home >> All >> [ echopoint overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC