import javax.swing.*;
import java.awt.Graphics;
import java.awt.*;
import java.awt.*;
 import java.awt.event.*;
 import java.awt.geom.*;
 import javax.swing.*;
 import java.net.*;
 import java.io.*;
 import java.awt.Graphics;
 import java.util.*;
 import java.text.*;
 import java.util.Locale;

public class hourP extends JPanel implements Runnable
{   
double second,minute,hour;
Thread runner;
Date c;

public hourP() 
{   c=new Date();
    // Türkiye is 3 hour advanced than Greenwith 
    String[] ids = TimeZone.getAvailableIDs(+3 * 60 * 60 * 1000);
    if (ids.length == 0)
    System.exit(0);
    SimpleTimeZone pdt = new SimpleTimeZone(+3 * 60 * 60 * 1000, ids[0]);
    GregorianCalendar calender=new GregorianCalendar(pdt);
    calender.setTime(c);
    second=calender.get(Calendar.SECOND);
    minute=calender.get(Calendar.MINUTE);
    hour=calender.get(Calendar.HOUR);
 runner=new Thread(this);
 runner.start();
}
public Line2D line(double A)
{double teta=(A*2.0*Math.PI)/60.0;
int xx=(int)(60+50.0*Math.cos(teta));
int yy=(int)(60-50.0*Math.sin(teta));
Line2D x3=new Line2D.Double(60,60,xx,yy);
return x3;
}
public Line2D[] setTime()
{ //I will use the computer time 
    c=new Date();
    // Türkiye is 3 hour advanced than Greenwith 
    String[] ids = TimeZone.getAvailableIDs(+3 * 60 * 60 * 1000);
    if (ids.length == 0)
    System.exit(0);
    SimpleTimeZone pdt = new SimpleTimeZone(+3 * 60 * 60 * 1000, ids[0]);
    GregorianCalendar calender=new GregorianCalendar(pdt);
    second=calender.get(Calendar.SECOND);
    minute=calender.get(Calendar.MINUTE);
    hour=calender.get(Calendar.HOUR);
    Line2D x3[]=new Line2D[3];
double teta1=((15-second)*2.0*Math.PI)/60.0;
int xx=(int)(60+50.0*Math.cos(teta1));
int yy=(int)(60-50.0*Math.sin(teta1));
x3[0]=new Line2D.Double(60,60,xx,yy);
double minute1=(minute+second/60);
double teta2=((15-minute1)*2.0*Math.PI)/60.0;
xx=(int)(60+40.0*Math.cos(teta2));
yy=(int)(60-40.0*Math.sin(teta2));

x3[1]=new Line2D.Double(60,60,xx,yy);	
double hour1=(hour+minute/60)%12;
double teta3=((3-hour1)*2.0*Math.PI)/12.0;
xx=(int)(60+30.0*Math.cos(teta3));
yy=(int)(60-30.0*Math.sin(teta3));

x3[2]=new Line2D.Double(60,60,xx,yy);	
return x3;
}

public void paint(Graphics g)
{
super.paintComponent(g);
Graphics2D g2=(Graphics2D)g;
 g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
 RenderingHints.VALUE_ANTIALIAS_ON);
 g2.setStroke(new BasicStroke(1.0f)); 
 Ellipse2D x=new Ellipse2D.Double(10,10,100,100); 
 g2.setColor(Color.yellow);
 g2.fill(x);  
 g2.setColor(Color.black); 
 g2.draw(x);
 x=new Ellipse2D.Double(5,5,110,110);
  g2.draw(x); 
 for(int i=0;i<12;i++)
 { Line2D x2=line(15+5.0*i); g2.draw(x2); }
g2.setColor(Color.blue); 
g2.setStroke(new BasicStroke(2.0f));
Line2D x3[]=setTime();
g2.draw(x3[0]);
g2.setStroke(new BasicStroke(3.0f));
g2.draw(x3[1]);
g2.setStroke(new BasicStroke(4.0f));
g2.draw(x3[2]);
}
     public void run()
     {
        while(true)
        {
	    try {Thread.sleep(1000);}
        catch(InterruptedException e)
        {System.err.println(e.toString());}
        repaint();
        }
    }

}


