–> We can implement animation by creating a timer, and when we need animation for a particular object, then we start the timer and inside timer, there is some animation related processing which gets executed to show the object differently on different time interval. The small changes in the object between the two time intervals gives the feeling of smooth animation.
We create a timer and when we need the animation, the timer is started, and the a block of code for animation executes which changes the look and position of object on the timer interval. After the animation is completed, we can reset the look or position of the object. The stopping condition of animation would be when timer is stopped or when some required state is reached by the object through animation.
We create a class for animation which does the task of animation as follows:
private class Animator implements ActionListener{
public void actionPerformed(ActionEvent e){//Do Animation}
}