import java.awt.Graphics;
//import java.util.*;
import java.applet.Applet;
import java.awt.Color;
import java.awt.Image;

public class BinClock extends Applet implements Runnable {

    private long timeStart;

	int lightCount = 16;
	int circlesize, top;

	Graphics offscreenGraphics;
	Image offscreenImage;


    private Thread clockThread = null;

		public void init() {
			offscreenImage = createImage(getBounds().width,getBounds().height);
			offscreenGraphics = offscreenImage.getGraphics();
			offscreenGraphics.setColor(Color.black);
			offscreenGraphics.fillRect(0,0,getBounds().width,getBounds().height);

			timeStart = System.currentTimeMillis();

			circlesize = getBounds().width / lightCount;


	}

    public void start() {
		top = (getBounds().height - circlesize) / 2;
        if (clockThread == null) {
            clockThread = new Thread(this, "BinClock");
            clockThread.start();
        }
    }

    public void run() {
        Thread myThread = Thread.currentThread();
        while (clockThread == myThread) {
            repaint();
            try {
                Thread.sleep(250);
            } catch (InterruptedException e){}
        }
    }



    public void paint(Graphics g) {
		long timeDiff = ((System.currentTimeMillis() - timeStart)/250);


		for(int i = 1; i < 16; i++){
			if( (timeDiff &   (1<<i))!= 0){
				offscreenGraphics.setColor(Color.red);
			} else {
				offscreenGraphics.setColor(Color.darkGray );
			}
			int left = ((lightCount - i) * circlesize );

			offscreenGraphics.fillOval(left,top, circlesize - 1, circlesize - 1);
		}

		g.drawImage(offscreenImage,0,0,this);

    }
    // overrides Applet's stop method, not Thread's
    public void stop() {
        clockThread = null;
    }
}


Content-Disposition: form-data; name="journal"

on