import java.awt.*;
import java.applet.*;
import java.util.*;
import java.text.*;

/* <applet code="DigiClock" width="200" height="200">
   </applet> */

/* Copyright Samar Abbas, Sept. 11 2000
   http://www.geocities.com/samarstan   */

public class DigiClock extends Applet implements Runnable
{
  Thread t;
  public void init()
  {
    String strings;
  }

  public void start()
  {
    t = new Thread(this);
    t.start();
  }


  public void paint(Graphics g)
  {

// Draw rectangle width 80, height 40
     setBackground(Color.black);
     g.setColor(Color.blue);
     g.fillRect( 50, 50, 100, 60 );
     g.setColor(Color.black);
     g.fillRect( 60, 60, 80, 40 );
     g.setColor(Color.yellow);
   Font f = new Font( "Arial", Font.BOLD, 26 );
   g.setFont(f);

// extract Date info, plot seconds first
  Date xdate = new Date();
    int hours = xdate.getHours();
    int mins = xdate.getMinutes();
    int secs = xdate.getSeconds();
      String shours = Integer.toString(hours);
      String smins = Integer.toString(mins);
      String ssecs = Integer.toString(secs);
  g.drawString(shours+":"+smins+":"+ssecs, 80, 80);
//  System.out.println(shours+smins+ssecs);

//  Graphics g2 = getGraphics();
  g.setColor(Color.red);
  FontMetrics fm = g.getFontMetrics();
  int sw = fm.stringWidth(shours);
  System.out.println(sw);
  g.drawRect( 60, 60, 60+sw, 100);



 }

 public void run()
 {
// without this the watch does not work
// remember which thread we are
  Thread ct = Thread.currentThread();
  while (ct == t)
     {
      try{ 
          t.sleep(1000);
          }
      catch(InterruptedException e)
          { System.out.println("Interrupted"); }
        repaint();
//      repaint(50,50,50,50);
//        update();
     }

 }

 public void stop()
 {
  t = null;
 }


}

