acm.util
Class SwingTimer

java.lang.Object
  extended by javax.swing.Timer
      extended by acm.util.SwingTimer

public class SwingTimer
extends Timer

This class is equivalent to javax.swing.Timer and exists only to avoid the ambiguity that arises because there is also a Timer class in java.util.


Constructor Summary
SwingTimer(int rate, ActionListener listener)
Creates a new timer that ticks at the specified rate.
 
Method Summary
 
Inherited Method Summary
voidaddActionListener(ActionListener listener)
Adds the specified action listener to the timer.
intgetDelay()
Returns the timer delay.
booleanisRepeats()
Returns true if the timer repeats.
booleanisRunning()
Returns true if the timer is running.
voidremoveActionListener(ActionListener listener)
Removes the specified action listener from the timer.
voidsetDelay(int delay)
Sets the timer delay in milliseconds.
voidsetRepeats(boolean flag)
Sets whether the timer repeats or is a one-shot event.
voidstart()
Starts the timer.
voidstop()
Stops the timer.
 

Constructor Detail

public SwingTimer(int rate, ActionListener listener)

Creates a new timer that ticks at the specified rate. On each tick, the timer sends an ActionEvent to the listener.

 
Usage: SwingTimer timer = new SwingTimer(rate, listener); 
Parameters: 
rate  The number of milliseconds between ticks
listener  The ActionListener receiving the events