|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnextapp.echo.AbstractComponent
echopoint.Timer
public class Timer
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 | |
|---|---|
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,
ActionListener actionListener)
Creates a Timer that will notify its
listeners every delay milliseconds. |
|
| Method Summary | |
|---|---|
void |
addActionListener(ActionListener l)
Adds an ActionListener to the Timer. |
void |
fireActionPerformed(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(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 |
|---|
public static final java.lang.String TIMER_CHANGED_PROPERTY
| Constructor Detail |
|---|
public Timer()
Timer that will notify its
listeners every 1000 milliseconds.
public Timer(int delay)
Timer that will notify its
listeners every delay milliseconds.
public Timer(int delay,
ActionListener actionListener)
Timer that will notify its
listeners every delay milliseconds.
| Method Detail |
|---|
public void addActionListener(ActionListener l)
ActionListener to the Timer.
l - The ActionListener to be added.public void fireActionPerformed(ActionEvent e)
e - The ActionEvent to send.public java.lang.String getActionCommand()
public int getDelay()
Timer.public int getInitialDelay()
Timer.public boolean hasFired()
Timer has fired beforepublic boolean isRepeats()
Timer will send a
actionPerformed() message to its listeners
multiple times.
public boolean isRunning()
Timer is running.public void removeActionListener(ActionListener l)
ActionListener from the Timer.
l - The ActionListener to be removed.public void restart()
Timer, canceling any pending firings, and causing
it to fire with its initial dely.
public void setActionCommand(java.lang.String newValue)
newValue - The new action command for this timer.public void setDelay(int newValue)
Timer's delay, the number of
milliseconds between successive actionPerfomed()
messages to its listeners
PropertyChangeEvent with a
getPropertyName() value of
Timer.TIMER_CHANGED_PROPERTY
public void setInitialDelay(int newValue)
Timer's initial delay. This will be
used for the first "ringing" of the Timer only. Subsequent
ringings will be spaced using the delay property.
PropertyChangeEvent with a
getPropertyName() value of
Timer.TIMER_CHANGED_PROPERTY
public void setRepeats(boolean newValue)
Timer to send actionPerformed()
to its listeners only once, and then stop.
PropertyChangeEvent with a
getPropertyName() value of
Timer.TIMER_CHANGED_PROPERTY
public void start()
Timer, causing it to send actionPerformed()
messages to its listeners.
public void stop()
Timer, causing it to stop sending actionPerformed()
messages to its listeners.
public java.lang.Object set(java.lang.reflect.Field field,
java.lang.Object newValue)
throws java.lang.Exception
ReflectionSetter
public Object set(Field f, Object newValue) throws Exception {
Object oldValue = f.get(this);
f.set(this,newValue);
return oldValue;
}
set in interface ReflectionSetterfield - - the field to be setnewValue - - the new value to be set
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.NullPointerException
java.lang.ExceptionReflectionSetter.set(Field, Object)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||