public class Animator
extends java.lang.Object
implements java.awt.event.ActionListener
ActionListener with a timer. It is used to simplify the animation of all kind of sliding windows.| Modifier and Type | Field and Description |
|---|---|
protected int |
_delay |
protected int |
_initialDelay |
| Constructor and Description |
|---|
Animator(java.awt.Component source)
Creates an animator for source with initDelay 50 ms, each step delays 10 ms and total 10 steps.
|
Animator(java.awt.Component source,
int initDelay,
int delay,
int totalSteps)
Creates an animator for source.
|
| Modifier and Type | Method and Description |
|---|---|
void |
actionPerformed(java.awt.event.ActionEvent e) |
void |
addAnimatorListener(AnimatorListener l)
Adds an
AnimatorListener to this Animator. |
protected javax.swing.Timer |
createTimer(int delay,
java.awt.event.ActionListener listener)
Creates the timer.
|
protected javax.swing.Timer |
createTimer(int initDelay,
int delay) |
void |
dispose() |
AnimatorListener[] |
getAnimatorListeners()
Returns an array of all the
AnimatorListeners added to this Animator with addAnimatorListener(). |
void |
interrupt()
Interrupts the animator.
|
boolean |
isRunning()
If the animator is running, returns true.
|
void |
removeAnimatorListener(AnimatorListener l)
Removes an
AnimatorListener from this Animator. |
void |
setDelay(int delay) |
void |
start()
Starts the animator.
|
void |
stop()
Stop the animator and reset the counter.
|
public Animator(java.awt.Component source)
source - the source for this animator.public Animator(java.awt.Component source,
int initDelay,
int delay,
int totalSteps)
source - the source for this animator.initDelay - the initial delay before timer starts.delay - the delay of the timertotalSteps - the number of steps. If -1, it means this animator will never stop until stop() is
called.protected javax.swing.Timer createTimer(int initDelay,
int delay)
protected javax.swing.Timer createTimer(int delay,
java.awt.event.ActionListener listener)
delay - the delay between each step, in ms.listener - the action listener associated with the timer.public void addAnimatorListener(AnimatorListener l)
AnimatorListener to this Animator.l - the AnimatorListener to be addedpublic void removeAnimatorListener(AnimatorListener l)
AnimatorListener from this Animator.l - the listener to be removedpublic AnimatorListener[] getAnimatorListeners()
AnimatorListeners added to this Animator with addAnimatorListener().AnimatorListeners added or an empty array if no listeners have been addedpublic void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed in interface java.awt.event.ActionListenerpublic void start()
public void stop()
public void interrupt()
public boolean isRunning()
public void setDelay(int delay)
public void dispose()