/*
*Clock Applet (VoodooClock.class)
*Developed solely by Ashish Hareet
*
*Comments & Suggestions will be appreciated
*Mail: gnashes30@yahoo.com
*
*This applet is my original work & was made to understand Thread's
*
*There are bound to be modified versions of the clock applet cause it can help you understand
*complex things like Fontmetrics , drawing shapes , etc - just a thought
*
*You may feel free to use this applet as is if you include a credit to me
*on your site along with my mail id
*
*You may also feel free to distribute it as long as the commented lines
*originally present are included in the class files
*
*If you wish to employ me mail me - gnashes30@yahoo.com
*
*Home page -
* www.VoodooStar.f2s.com
* www.geocities.com/gnashes30
*
*/

import java.awt.*;
import java.util.*;
import java.applet.*;
import java.text.*;

/*
<applet code="VoodooClock" width=300 height="100">
</applet>
*/

public class VoodooClock extends Applet implements Runnable{

	private Thread th = null;
	private boolean flag = true;

	public void init(){
		getParent().setBackground(Color.white);
		setForeground(Color.blue);
		Font f = new Font("Arial" , Font.CENTER_BASELINE , 25);
		setFont(f);
	}

	public void start(){
		if (flag)
		{
			th = new Thread(this);
			th.start();
		}
	}

	public void run(){
		while (flag)
		{
			repaint();
			try
			{
				Thread.sleep(1000);
			}
			catch (InterruptedException e){}
		}
	}

	public void paint(Graphics g){
		Calendar cal = Calendar.getInstance();
        Date time = cal.getTime();
        DateFormat obj_l = DateFormat.getTimeInstance(DateFormat.LONG);
        g.drawString(obj_l.format(time), 15, 30);
		DateFormat obj_m = DateFormat.getTimeInstance(DateFormat.MEDIUM);
        g.drawString(obj_m.format(time), 75, 60);
		DateFormat obj_s = DateFormat.getTimeInstance(DateFormat.SHORT);
        g.drawString(obj_s.format(time), 90, 90);
	}

	public void stop(){
		flag = false;
	}
};