Package com.jidesoft.swing
Class Animator
- java.lang.Object
-
- com.jidesoft.swing.Animator
-
- All Implemented Interfaces:
java.awt.event.ActionListener,java.util.EventListener
public class Animator extends java.lang.Object implements java.awt.event.ActionListenerAnActionListenerwith a timer. It is used to simplify the animation of all kind of sliding windows.
-
-
Field Summary
Fields Modifier and Type Field Description protected int_delayprotected int_initialDelay
-
Constructor Summary
Constructors Constructor 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactionPerformed(java.awt.event.ActionEvent e)voidaddAnimatorListener(AnimatorListener l)Adds anAnimatorListenerto this Animator.protected javax.swing.TimercreateTimer(int initDelay, int delay)protected javax.swing.TimercreateTimer(int delay, java.awt.event.ActionListener listener)Creates the timer.voiddispose()AnimatorListener[]getAnimatorListeners()Returns an array of all theAnimatorListeners added to this Animator with addAnimatorListener().voidinterrupt()Interrupts the animator.booleanisRunning()If the animator is running, returns true.voidremoveAnimatorListener(AnimatorListener l)Removes anAnimatorListenerfrom this Animator.voidsetDelay(int delay)voidstart()Starts the animator.voidstop()Stop the animator and reset the counter.
-
-
-
Constructor Detail
-
Animator
public Animator(java.awt.Component source)
Creates an animator for source with initDelay 50 ms, each step delays 10 ms and total 10 steps.- Parameters:
source- the source for this animator.
-
Animator
public Animator(java.awt.Component source, int initDelay, int delay, int totalSteps)Creates an animator for source.- Parameters:
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 untilstop()is called.
-
-
Method Detail
-
createTimer
protected javax.swing.Timer createTimer(int initDelay, int delay)
-
createTimer
protected javax.swing.Timer createTimer(int delay, java.awt.event.ActionListener listener)Creates the timer.- Parameters:
delay- the delay between each step, in ms.listener- the action listener associated with the timer.- Returns:
- the timer
-
addAnimatorListener
public void addAnimatorListener(AnimatorListener l)
Adds anAnimatorListenerto this Animator.- Parameters:
l- theAnimatorListenerto be added
-
removeAnimatorListener
public void removeAnimatorListener(AnimatorListener l)
Removes anAnimatorListenerfrom this Animator.- Parameters:
l- the listener to be removed
-
getAnimatorListeners
public AnimatorListener[] getAnimatorListeners()
Returns an array of all theAnimatorListeners added to this Animator with addAnimatorListener().- Returns:
- all of the
AnimatorListeners added or an empty array if no listeners have been added
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
- Specified by:
actionPerformedin interfacejava.awt.event.ActionListener
-
start
public void start()
Starts the animator.
-
stop
public void stop()
Stop the animator and reset the counter.
-
interrupt
public void interrupt()
Interrupts the animator. The counter is not reset in this case.
-
isRunning
public boolean isRunning()
If the animator is running, returns true. Otherwise, returns false.- Returns:
- true if animator is running. Otherwise, returns false.
-
setDelay
public void setDelay(int delay)
-
dispose
public void dispose()
-
-