24.3 Animating a Series of Images
Next, we animate a series of images stored in an array of ImageIcon
s. In this example, we use the JNLP FileOpenService
to enable the user to choose a group of images that will be animated by displaying one image at a time at 50-millisecond intervals. The animation presented in Figs. 24.4–24.5 is implemented using a subclass of JPanel
called LogoAnimatorJPanel
(Fig. 24.4) that can be attached to an application window or a JApplet
. Class LogoAnimator
(Fig. 24.5) declares a main
method (lines 8–20 of Fig. 24.5) 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.
Get Java How to Program (early objects), 9/e now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.