All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jp.kyasu.awt.Timer

java.lang.Object
   |
   +----jp.kyasu.awt.Timer

public class Timer
extends Object
implements Serializable
The Timer object causes an action to occur at a predefined rate. For example, an animation object can use a Timer as the trigger for drawing its next frame. 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.

Using a Timer involves first creating it, then starting it using the start() method.

The API of this class is designed based on com.sun.java.swing.Timer in swing 0.5.1, but the implementation of this class is original.

Version:
16 Dec 1998
Author:
Kazuki YASUMATSU

Constructor Index

 o Timer(int, ActionListener)
Constructs a timer that will notify its listeners every delay milliseconds.
 o Timer(int, int, ActionListener)
Constructs a timer that will notify its listeners every delay milliseconds.

Method Index

 o addActionListener(ActionListener)
Adds an actionListener to the timer.
 o getDelay()
Returns the timer's delay.
 o getInitialDelay()
Returns the timer's initial delay.
 o isRunning()
Returns true if the timer is running.
 o removeActionListener(ActionListener)
Removes an ActionListener from the timer.
 o repeats()
Returns true if the timer will send a actionPerformed() message to its listeners multiple times.
 o restart()
Restarts the timer, cancelling any pending firings, and causing it to fire with its initial dely.
 o setDelay(int)
Sets the timer's delay, the number of milliseconds between successive actionPerfomed() messages to its listeners.
 o setInitialDelay(int)
Sets the timer's initial delay.
 o setRepeats(boolean)
If the specified flag is false, instructs the timer to send actionPerformed() to its listeners only once, and then stop.
 o start()
Starts the timer, causing it to send actionPerformed() messages to its listeners.
 o stop()
Stops the timer, causing it to stop sending actionPerformed() messages to its listeners.

Constructors

 o Timer
 public Timer(int delay,
              ActionListener listener)
Constructs a timer that will notify its listeners every delay milliseconds.

Parameters:
delay - The number of milliseconds between listener notification.
listener - An initial listener.
 o Timer
 public Timer(int initialDelay,
              int delay,
              ActionListener listener)
Constructs a timer that will notify its listeners every delay milliseconds.

Parameters:
initialDelay - the initial delay.
delay - The number of milliseconds between listener notification.
listener - An initial listener.

Methods

 o addActionListener
 public synchronized void addActionListener(ActionListener l)
Adds an actionListener to the timer.

 o removeActionListener
 public synchronized void removeActionListener(ActionListener l)
Removes an ActionListener from the timer.

 o getInitialDelay
 public synchronized int getInitialDelay()
Returns the timer's initial delay.

 o setInitialDelay
 public synchronized void setInitialDelay(int initialDelay)
Sets the 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.

 o getDelay
 public synchronized int getDelay()
Returns the timer's delay.

 o setDelay
 public synchronized void setDelay(int delay)
Sets the timer's delay, the number of milliseconds between successive actionPerfomed() messages to its listeners.

 o repeats
 public synchronized boolean repeats()
Returns true if the timer will send a actionPerformed() message to its listeners multiple times.

 o setRepeats
 public synchronized void setRepeats(boolean flag)
If the specified flag is false, instructs the timer to send actionPerformed() to its listeners only once, and then stop.

 o isRunning
 public synchronized boolean isRunning()
Returns true if the timer is running.

 o start
 public synchronized void start()
Starts the timer, causing it to send actionPerformed() messages to its listeners.

 o stop
 public synchronized void stop()
Stops the timer, causing it to stop sending actionPerformed() messages to its listeners.

 o restart
 public synchronized void restart()
Restarts the timer, cancelling any pending firings, and causing it to fire with its initial dely.


All Packages  Class Hierarchy  This Package  Previous  Next  Index