public class UDCSimpleTimer
extends java.lang.Object
Constructor and Description |
---|
UDCSimpleTimer(int delay,
java.awt.event.ActionListener listener)
Construct the timer, providing the object for which an action will be
performed and the amount of time (in milliseconds) between those
actions.
|
UDCSimpleTimer(int delay,
java.awt.event.ActionListener listener,
int repeat)
Construct the timer, providing the object for which an action will be
performed and the amount of time (in milliseconds) between those
actions.
|
UDCSimpleTimer(long delay,
java.awt.event.ActionListener listener) |
UDCSimpleTimer(long delay,
java.awt.event.ActionListener listener,
int repeat) |
Modifier and Type | Method and Description |
---|---|
boolean |
isHealthy() |
boolean |
isRunning()
Indicates whether the timer is running
|
void |
restart()
Reset the timer.
|
void |
restart(int delay)
Reset the timer.
|
void |
setRepeats(boolean repeat)
If
repeat is false , the timer to send
actionPerformed() to its listener only once, and then stop. |
void |
skipToEvent(boolean skip)
Causes or prevents the current timer iteration to/from proceeding
to the next event.
|
void |
start()
Start the timer
|
void |
stop()
Stop the timer.
|
public UDCSimpleTimer(int delay, java.awt.event.ActionListener listener)
start()
method has been called, the
timer will continue to cycle until the stop()
method is
called.delay
- The number of milliseconds this timer will sleep
between calls to the ActionListener
.listener
- An ActionListener
object which will
have its actionPerformed()
method
called when the timer's 'delay' time has expired.public UDCSimpleTimer(long delay, java.awt.event.ActionListener listener)
public UDCSimpleTimer(int delay, java.awt.event.ActionListener listener, int repeat)
start()
method has been called, the
timer will cycle as many times as indicated by the value of
repeat
. A value of zero (0) indicates the timer should
run until the stop()
method is called.delay
- The number of milliseconds this timer will sleep
between calls to the ActionListener
.listener
- An ActionListener
object which will
have its actionPerformed()
method
called the timer's 'delay' time has expired.repeat
- Number of times this timer will run.public UDCSimpleTimer(long delay, java.awt.event.ActionListener listener, int repeat)
public boolean isRunning()
public void setRepeats(boolean repeat)
repeat
is false
, the timer to send
actionPerformed() to its listener only once, and then stop. This
method exists to mimic the javax.swing.Timer class. However, a
finer granularity can be achieved by setting the repeat value via
the constructor.public void start()
public void restart()
public void skipToEvent(boolean skip)
skip
- true, to skip the NEXT timer, or interrupt
the current timer. false, to proceed as normalpublic void restart(int delay)
delay
- Resets the delay of the timer to the given valuepublic void stop()
public boolean isHealthy()