import java.awt.*;

/* This example extends DrawImage,
 * to draw the face of an ImageButton,
 * and implements Runnable,
 * with a timer Thread to animate the image.
 * @author Morris Hirsch IPD */

public class WhiteBar extends DrawImage implements Runnable {

/* Coordinate that changes for animation */

    private int xx = 0;

    public void draw (Graphics g, int xo, int yo, boolean enabled) {

/* Declare our colors and gray them if disabled */

	Color Cgreen = Color.green;
	Color Cyellow = Color.yellow;
	Color Cred = Color.red;
	Color Cwhite = Color.white;

        if (!enabled) {
	   Cgreen = BWFilter (Color.green);
	   Cyellow = BWFilter (Color.yellow);
	   Cred = BWFilter (Color.red);
	   Cwhite = BWFilter (Color.white);
	}

/* Draw the constant part */

	g.setColor (Cgreen);
	g.fillRect (xo+0, yo+0, 32, 11);
	g.setColor (Cyellow);
	g.fillRect (xo+0, yo+11, 32, 11);
	g.setColor (Cred);
	g.fillRect (xo+0, yo+22, 32, 11);
	g.setColor (Cwhite);
	g.fillRect (xo+15, yo+3, 3, 28);

/* Draw the animated part -- a moving vertical bar */

	g.setColor (Color.black);
	g.fillRect (xo+xx, yo, 3, 32);
    }

/* Called early and never again */

    public int getHeight () { return 32; }

    public int getWidth () { return 32; }

/* Constructor creates and starts a thread,
   with (this) as runnable target. */

    WhiteBar () { new Thread (this).start (); }

/* Animate the image and schedule repaints. */

    public void run () {
	while (true) {
	    try { Thread.sleep (1000); }
	    catch (Exception exc) {}
	    xx += 3;
	    if (xx > 30)
	        xx = 0;
          repaint (20);
      }
   }
}
/* <IMG SRC="/cgi-bin/counter">*/
