O'Reilly logo

Platinum Edition Using XHTML™, XML, and Java™ 2 by Andrew H. Watt, Mike Morgan, Jim O'Donnell, Eric Ladd

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding Animation

As you develop your user interfaces—particularly user interfaces for applets—you might find a need for animation. The previous section explored drawImage(); it is the graphical analog of drawString() that you've been using for a while. Listing 38.7 illustrates an animation technique you might consider using.

Code Listing 38.7. Animation1.java—This Applet Loads and Displays a Series of Images in Rapid Succession
 import java.awt.*; import java.applet.Applet; public class Animation1 extends Applet implements Runnable { int fFrame = -1; int fDelay; Thread fThread; Image[] fEarth; public void init() { fEarth = new Image[30]; String theString; int theFramesPerSecond = 10; //load in the images for (int i=1; i<=30; i++) { System.err.println("Starting ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required