public class Animator extends Object implements ActionListener
ActionListener with a timer. It is used to simplify the animation of all kind of sliding windows.| Constructor and Description |
|---|
Animator(Component source)
Creates an animator for source with initDelay 50 ms, each step delays 10 ms and total 10 steps.
|
Animator(Component source,
int initDelay,
int delay,
int totalSteps)
Creates an animator for source.
|
| Modifier and Type | Method and Description |
|---|---|
void |
actionPerformed(ActionEvent e) |
void |
addAnimatorListener(AnimatorListener l)
Adds an
AnimatorListener to this Animator. |
protected Timer |
createTimer(int delay,
ActionListener listener)
Creates the timer.
|
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(Component source)
source - the source for this animator.public Animator(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 Timer createTimer(int delay, 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(ActionEvent e)
actionPerformed in interface ActionListenerpublic void start()
public void stop()
public void interrupt()
public boolean isRunning()
public void setDelay(int delay)
public void dispose()
Copyright © 2017. All rights reserved.