public class OneShotTimer extends Object
Constructor and Description |
---|
OneShotTimer(long d,
ActionListener l)
Creates a new OneShotTimer that stays in the timer queue after posting.
|
OneShotTimer(long d,
ActionListener l,
boolean deleteOnPostIn)
Creates a new OneShotTimer.
|
Modifier and Type | Method and Description |
---|---|
void |
clean()
Releases resources used by this timer.
|
long |
getExpirationTime()
Gets the expiration time for this timer, in nanoseconds, relative to
System.nanoTime() . |
boolean |
isRunning()
Determines if this timer is active.
|
void |
setDelay(long d)
Sets the delay for this timer.
|
void |
start()
Starts the timer.
|
public OneShotTimer(long d, ActionListener l)
clean()
should be called if the timer will not be used again.d
- the time delay in nanoseconds.l
- listener that will be notified when the timer expires. The
ActionEvent parameter will be null.public OneShotTimer(long d, ActionListener l, boolean deleteOnPostIn)
d
- the time delay in nanoseconds.l
- listener that will be notified when the timer expires. The
ActionEvent parameter will be null.deleteOnPostIn
- if true, the timer will be removed from the timer
queue after posting. This should be set to true if the timer will only be
used once. If this is false, clean()
should be called if the
timer will not be used again.public void clean()
public long getExpirationTime()
System.nanoTime()
.public boolean isRunning()
public void setDelay(long d)
d
- the new timer delay, in nanoseconds.public void start()