Sky View Café - Java

org.shetline.util
Class RepeatingComponentAction

java.lang.Object
  extended by org.shetline.util.RepeatingComponentAction

public class RepeatingComponentAction
extends Object

A periodically repeating action based on the visibility of a component.


Field Summary
protected  Runnable action
           
protected  Component comp
           
protected  int delay
           
protected  String name
           
protected  boolean onEventDispatch
           
protected  Thread repeater
           
protected  boolean stopped
           
 
Constructor Summary
RepeatingComponentAction(Component comp, int delay, boolean onEventDispatch, Runnable action)
          Constructs a RepeatingComponentAction for the given component.
RepeatingComponentAction(Component comp, int delay, boolean onEventDispatch, String name, Runnable action)
          Constructs a RepeatingComponentAction for the given component.
 
Method Summary
 void actNow()
          Skip over any remaining delay until the next repetition and perform the repeated action immediately (or as immediately as waiting for SwingUtilities.isEventDispatchThread() permits).
 void setName(String name)
          Sets the name of the thread which handles periodic repetition - useful for debugging.
 void start()
          Starts repeater if not already running.
 void stop()
          Stops repeater.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

action

protected Runnable action

comp

protected Component comp

delay

protected int delay

name

protected String name

onEventDispatch

protected boolean onEventDispatch

repeater

protected Thread repeater

stopped

protected boolean stopped
Constructor Detail

RepeatingComponentAction

public RepeatingComponentAction(Component comp,
                                int delay,
                                boolean onEventDispatch,
                                Runnable action)
Constructs a RepeatingComponentAction for the given component.

Parameters:
comp - Component for a repeating action.
delay - Time (in milliseconds) between each repetition of action.
onEventDispatch - If true, perform action on the AWT event dispatch thread.
action - The action to perform periodically.

RepeatingComponentAction

public RepeatingComponentAction(Component comp,
                                int delay,
                                boolean onEventDispatch,
                                String name,
                                Runnable action)
Constructs a RepeatingComponentAction for the given component.

Parameters:
comp - Component for a repeating action.
delay - Time (in milliseconds) between each repetition of action.
onEventDispatch - If true, perform action on the AWT event dispatch thread.
name - Name for the thread which handles periodic repetition. Unique thread names are useful when debugging.
action - The action to perform periodically.
Method Detail

setName

public void setName(String name)
Sets the name of the thread which handles periodic repetition - useful for debugging.

Parameters:
name - Name for thread.

start

public void start()
Starts repeater if not already running.


stop

public void stop()
Stops repeater.


actNow

public void actNow()
Skip over any remaining delay until the next repetition and perform the repeated action immediately (or as immediately as waiting for SwingUtilities.isEventDispatchThread() permits). Timing cycle will be reset and the next repetition will occur after a full delay. If the repeater isn't running when this method is called, a single-shot action is performed.


Sky View Café - Java