FileDocCategorySizeDatePackage
AnimateApplet.javaAPI DocExample1450Mon Mar 24 02:01:06 GMT 1997None

AnimateApplet

public class AnimateApplet extends Applet implements Runnable

Fields Summary
static Image[]
im
static int
numImages
static int
counter
Thread
animator
Constructors Summary
Methods Summary
public voidinit()

        
        im = new Image[numImages];
        for (int i=0;i<numImages;i++)
            im[i] = getImage (getDocumentBase(), "clock"+i+".jpg");
    
public voidpaint(java.awt.Graphics g)

        g.drawImage (im[counter], 0, 0, this);
    
public voidrun()

        while (animator != null) {
            try {
                animator.sleep(200);
                repaint ();
                counter++;
                if (counter==numImages)
                    counter=0;
            } catch (Exception e) {
                e.printStackTrace ();
            }
        }
    
public voidstart()

        if (animator == null) {
            animator = new Thread (this);
            animator.start ();
        }
    
public voidstop()

        if ((animator != null) && (animator.isAlive())) {
            animator.stop();
            animator = null;
        }