ui
Class Stopwatch

java.lang.Object
  extended by java.util.TimerTask
      extended by ui.Stopwatch
All Implemented Interfaces:
Runnable

public class Stopwatch
extends TimerTask


Constructor Summary
Stopwatch(long millisLeft)
           
 
Method Summary
 void addStopwatchListener(StopwatchListener s)
          Adds a StopwatchListener to this.
protected  void fireTimeChanged()
          Informs all of this Stopwatch's listeners that its time is decreasing
 long getTime()
          Returns the amount of time left on the Stopwatch (or zero, if that time is less than zero).
 void removeStopwatchListener(StopwatchListener s)
          Removes a StopwatchListener from this
 void run()
          Informs all of this Stopwatch's listeners that its time is decreasing
 void start()
          Starts the timer, if it was not already running.
 void stop()
          Stops the timer, if it was not already stopped.
 
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Stopwatch

public Stopwatch(long millisLeft)
Requires:
millisLeft >= 0
Method Detail

start

public void start()
Starts the timer, if it was not already running.


stop

public void stop()
Stops the timer, if it was not already stopped.


getTime

public long getTime()
Returns the amount of time left on the Stopwatch (or zero, if that time is less than zero).


addStopwatchListener

public void addStopwatchListener(StopwatchListener s)
Adds a StopwatchListener to this. The listener's timeChanged method will fire everytime this is run as a TimerTask.


removeStopwatchListener

public void removeStopwatchListener(StopwatchListener s)
Removes a StopwatchListener from this


fireTimeChanged

protected void fireTimeChanged()
Informs all of this Stopwatch's listeners that its time is decreasing


run

public void run()
Informs all of this Stopwatch's listeners that its time is decreasing

Specified by:
run in interface Runnable
Specified by:
run in class TimerTask