/** * This applet displays an animation. It doesn't handle errors while * loading images. It doesn't wait for all images to be loaded before * starting the animation. This stuff will be addressed elsewhere. **/ import java.applet.*; import java.awt.*; import java.net.*; import java.util.*; public class Animator extends Applet implements Runnable { protected Image[] images; protected int current_image; protected int sleep; // REad the basename and num_images parameters // The read in the images, using the specified base name. // For example, if basename is images/anim, read images/anim0, // images/anim1, etc. These are relative to the current document URL. public void init() { String basename = this.getParameter("basename"); int num_images; try { num_images = Integer.parseInt(this.getParameter("num_images")); } catch (NumberFormatException e) { num_images = 0; } images = new Image[num_images]; for (int i = 0; i= images.length) current_image = 0; this.getGraphics().drawImage(images[current_image],0,0,this); showStatus("frame: " + current_image); try {Thread.sleep(sleep);} catch (InterruptedException e); } } }