ks.client.gamefactory.timer
Class Timer

java.lang.Object
  |
  +--ks.client.gamefactory.timer.Timer
All Implemented Interfaces:
java.lang.Runnable, java.io.Serializable

public class Timer
extends java.lang.Object
implements java.lang.Runnable, java.io.Serializable

Manages a timer. Sets a timer to wait before an action event is posted to a component. The caller can specify the time delay and whether this repeats. The timer is implemented as a thread. The one of the start(...) methods should be called to start the thread. Creation date: (10/16/01 7:27:56 PM)

See Also:
Serialized Form

Field Summary
protected  java.lang.String actionCommand
           
protected  java.awt.event.ActionListener actionListener
           
protected  int delay
           
protected  boolean execute
           
protected  boolean live
           
protected  boolean repeat
           
protected  java.lang.Thread thread
           
 
Constructor Summary
Timer()
          Creates a timer with the default delay.
Timer(boolean r)
          Creates a timer with specified repeat setting and the default delay.
Timer(int d)
          Creates a timer with specified delay.
Timer(int d, boolean r)
          Creates a timer with specified delay and repeat setting.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener l)
          Adds the specified action listener to receive action events from this button.
 java.lang.String getActionCommand()
          Returns the command name of the action event fired by this button.
 int getDelay()
          Obtains the delay time setting for this timer.
 boolean isEnabled()
          Determine if we are enabled.
 boolean isRepeat()
          Obtains the repeat setting of the timer.
 void pause()
          Pauses the timer.
 void removeActionListener(java.awt.event.ActionListener l)
          Removes the specified action listener so it no longer receives action events from this button.
 void restart()
          Restarts the timer immediately with the current delay value.
 void resume()
          Resumes the timer.
 void run()
          The thread body.
 void setActionCommand(java.lang.String newActionCommand)
          Sets the command name of the action event fired by this button.
 void setDelay(int newDelay)
          Sets the delay time for this timer.
 void setRepeat(boolean newRepeat)
          Changes the repeat setting of the timer.
 void start()
          Starts the timer with existing settings.
 void start(boolean r)
          Starts the timer using the specified repeat setting.
 void start(int d)
          Starts the timer using the specified delay setting
 void start(int d, boolean r)
          Starts the timer using the specified delay and repeat settings.
 void stop()
          Stops the timer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

repeat

protected boolean repeat

execute

protected boolean execute

live

protected boolean live

delay

protected int delay

actionCommand

protected java.lang.String actionCommand

actionListener

protected java.awt.event.ActionListener actionListener

thread

protected transient java.lang.Thread thread
Constructor Detail

Timer

public Timer()
Creates a timer with the default delay. After 1000 miliseconds this timer will fire an ActionEvent. It will not repeat. Creation date: (10/16/01 7:29:12 PM)


Timer

public Timer(int d)
Creates a timer with specified delay. After the specified delay this timer will fire an ActionEvent. It will not repeat. Creation date: (10/16/01 7:29:55 PM)

Parameters:
d - the delay in milliseconds

Timer

public Timer(int d,
             boolean r)
Creates a timer with specified delay and repeat setting. After the specified delay this timer will fire an ActionEvent. It may repeat, depending on r. Creation date: (10/16/01 7:31:34 PM)

Parameters:
d - the delay in milliseconds
r - if true, reset and repeat after generating the event

Timer

public Timer(boolean r)
Creates a timer with specified repeat setting and the default delay. After 1000 miliseconds this timer will fire an ActionEvent. It may repeat, depending on r. Creation date: (10/16/01 7:30:40 PM)

Parameters:
r - if true, reset and repeat after generating the event
Method Detail

addActionListener

public void addActionListener(java.awt.event.ActionListener l)
Adds the specified action listener to receive action events from this button. Creation date: (10/16/01 7:38:53 PM)

Parameters:
l - the action listener

getActionCommand

public java.lang.String getActionCommand()
Returns the command name of the action event fired by this button.

Returns:
java.lang.String
See Also:
Creation date: (10/16/01 7:40:03 PM)

getDelay

public int getDelay()
Obtains the delay time setting for this timer. Creation date: (10/16/01 7:40:03 PM)

Returns:
the current delay setting for this timer, in milliseconds
See Also:
setDelay(int)

isEnabled

public boolean isEnabled()
Determine if we are enabled. Creation date: (10/16/01 7:40:13 PM)

Returns:
boolean

isRepeat

public boolean isRepeat()
Obtains the repeat setting of the timer. Creation date: (10/16/01 7:40:03 PM)

Returns:
true if this timer is set to repeat, false if this timer does not repeat
See Also:
setRepeat(boolean)

pause

public void pause()
Pauses the timer. Differs from stop in that the timer is continued from whatever state it was in before pausing.

start() and stop() overrule this function. Creation date: (10/16/01 7:32:48 PM)

See Also:
resume(), start(), stop()

removeActionListener

public void removeActionListener(java.awt.event.ActionListener l)
Removes the specified action listener so it no longer receives action events from this button.

Parameters:
l - the action listener Creation date: (10/16/01 7:37:28 PM)

restart

public void restart()
Restarts the timer immediately with the current delay value. This will start a stopped timer.

See Also:
start(), stop()

resume

public void resume()
Resumes the timer. Differs from start in that the timer is continued from whatever state it was in before pausing.

start() and stop() overrule this function Creation date: (10/16/01 7:33:46 PM)

See Also:
pause(), start(), stop()

run

public void run()
The thread body. This method is called by the Java virtual machine in response to a start call by the user. Creation date: (10/16/01 7:35:20 PM)

Specified by:
run in interface java.lang.Runnable
See Also:
start(), start(int), start(boolean), start(int, boolean), stop()

setActionCommand

public void setActionCommand(java.lang.String newActionCommand)
Sets the command name of the action event fired by this button. Creation date: (10/16/01 7:40:03 PM)

Parameters:
newActionCommand - java.lang.String
See Also:
if the specified property value is unacceptable

setDelay

public void setDelay(int newDelay)
Sets the delay time for this timer. Creation date: (10/16/01 7:40:03 PM)

See Also:
getDelay()

setRepeat

public void setRepeat(boolean newRepeat)
Changes the repeat setting of the timer. If the repeat setting is false a single event will be generated. When set to true the timer produces a series of events. Creation date: (10/16/01 7:40:03 PM)

See Also:
isRepeat()

start

public void start()
Starts the timer with existing settings. Creation date: (10/16/01 7:34:31 PM)

See Also:
start(int), start(boolean), start(int, boolean), stop(), run()

start

public void start(int d)
Starts the timer using the specified delay setting

Parameters:
d - the delay in milliseconds
See Also:
start(), start(int), start(boolean), stop(), run()

start

public void start(int d,
                  boolean r)
Starts the timer using the specified delay and repeat settings.

Parameters:
d - the delay in milliseconds
r - reset and repeat after generating the event if the specified property value is unacceptable
See Also:
start(), start(int), start(boolean), stop(), run()

start

public void start(boolean r)
Starts the timer using the specified repeat setting.

Parameters:
r - reset and repeat after generating the event if the specified property value is unacceptable
See Also:
start(), start(int), start(boolean), stop(), run()

stop

public void stop()
Stops the timer. After return the timer will generate no more events. Creation date: (10/16/01 7:46:08 PM)

See Also:
start()