- All Implemented Interfaces:
An animation that is driven by a Swing Timer. A concrete subclass of this class must implement the
- Direct Known Subclasses:
drawFrame()method, which is called each time the Timer fires. A subclass that has some set-up to do at the beginning of the animation should override the
animationStarting()method; if the subclass has some clean-up that needs to be done when the animation ends, it should override
animationEnding(). Note that the animation does not start until its
start()method is invoked. Once it has been started, it will run until it ends on its own or until its
cancel()method is called, either by an external agent or in the
drawFramemethod. While it is running, a TimerAnimation can be paused and resumed by calling the
Each frame in a TimerAnimation has a frame number. It can have either a specified finite number of frames, or the frame number can be allowed to increase indiefinitely. An animation with a finite number of frames can run in any of three "looping modes":
TimerAnimation.ONCE, meaning that it runs through the frames from first to last then stops;
TimerAnimation.LOOP, which means that it runs from first to last frame over and over indefinitely; and
TimerAnimation.OSCILLATE, which means that it runs from first frame to last then from last frame back to first in revese order, and the repeats this sequence indefinitely.
A Timere animation is capable of using a "filmstrip" to store the frames of the animation. See
setUseFilmstrip(boolean). If a filmstrip is used, each frame of the animation is saved as a bitmap the first time it is computed. Then, when it is necessary to show the same frame again, the precomputed bitmap is just copied to the screen.