 import java.awt.*;
 import javax.swing.*;
 import java.util.*;
public class Orologio extends JApplet implements Runnable 
 {
    
  Display disegno;
  int lunghezza, larghezza;
  Color  ore [];
  int x,y,r;
  Thread animazione;
  int ora;
  Date d;

 public void init(){
   disegno = new Display();
   setContentPane(disegno);
   ora = 75;
   ore = new Color[12];
   ore[0] = new Color(255,234,32);
   ore[11] = new Color(255,125,24);
   ore[10] = new Color(255,194,197); 
   ore[9] = new Color(213,32,41);
   ore[8] = new Color(255,105,205);
   ore[7] = new Color(189,24,164);
   ore[6] = new Color(65,64,189);
   ore[5] = new Color(41,125,41);
   ore[4] = new Color(0,194,197);
   ore[3] = new Color(156,72,49);
   ore[2] = new Color(230,214,189);
   ore[1] = new Color(205,153,106);   
   x = 10;y=10; r=70;
   }
public void start() { if (animazione == null) 
{ animazione = new Thread(this); animazione.start(); } } 
public void stop() { if (animazione != null) { animazione = null; } } 
public void run() {
    int nminuti;
    while(true) {
    
    d = new Date();
  nminuti = d.getHours()*60+d.getMinutes();
  nminuti = nminuti%(12*60);
  ora = (int)(360.* nminuti/(double)(12*60));   
  ora = (-ora - 75 -180); 
//System.out.println(ora + " " +d+" "+d.getHours()+" "+    
//       d.getMinutes());
        disegno.repaint();
        try { Thread.sleep(10000);}
       catch (InterruptedException e) { }
  
 } 
}

class Display extends JPanel {
 //  Display(){ setBackground(new Color(200,200,200);}
   public void paintComponent(Graphics g){
       super.paintComponent(g);
       lunghezza = getSize().width;
       larghezza = getSize().height;
       for ( int i=0; i < ore.length; i++) {
          g.setColor(ore[i]);
          g.fillArc(x,y,2*r,2*r,(i*30)+75,30);
       }
       g.setColor(Color.gray);
       g.fillArc(x,y,2*r,2*r,ora,330);
          
       
} 
}
  
}
