The next example demonstrates animating a series of images that are stored in an array of ImageIcons. The animation presented in Figs. 21.2–21.3 is implemented using a subclass of JPanel called LogoAnimatorJPanel (Fig. 21.2) that can be attached to an application window or a JApplet. Class LogoAnimator (Fig. 21.3) declares a main method (lines 8–20 of Fig. 21.3) to execute the animation as an application. Method main declares an instance of class JFrame and attaches a LogoAnimatorJPanel object to the JFrame to display the animation.
1 // Fig. 21.2: LogoAnimatorJPanel.java 2 // Animation of a series of images. 3 import java.awt.Dimension; 4 import java.awt.event.ActionEvent; ...