import java.awt.Graphics;
 import java.awt.*;
 import java.util.*;
 import javax.swing.*;
 import java.text.*;


 class saatThreadSWF extends Thread
 {
 JFrame a;
 public saatThreadSWF(JFrame ai)
 {a=ai;}

 public void run()
 {
 while(true)
 {
 a.validate();
 a.repaint();
 try {Thread.sleep(1000);}
 catch(InterruptedException e)
 {System.err.println(e.toString());}
 }
 }
 }

 public class saatSWF extends JFrame
 {
 JLabel jb;
 Font F;
 Date D;
 saatThreadSWF r;
 GregorianCalendar takvim;

 public saatSWF()
 {
 super("Digital Saat extends Thread");
 Container cc=getContentPane();
 jb=new JLabel("");
 F=new Font("TimesRoman",Font.BOLD,24);
 jb.setFont(F);
 // Türkiye standart (Greenwitch zamanına göre iki saat ileride)
 String[] ids = TimeZone.getAvailableIDs(+2 * 60 * 60 * 1000);
 SimpleTimeZone pdt = new SimpleTimeZone(+2 * 60 * 60 * 1000, ids[0]);
 takvim=new GregorianCalendar(pdt);
 D=new Date();
 takvim.setTime(D);
 r=new saatThreadSWF(this);
 cc.add(jb);
 r.start();
 }

 public void paint(Graphics g)
 {
     D=new Date();
     takvim.setTime(D);
     String s="      ["+
     takvim.get(Calendar.DATE) +" / "+
     takvim.get(Calendar.MONTH)+" / "+
     takvim.get(Calendar.YEAR) +" ] "+
     takvim.get(Calendar.HOUR_OF_DAY)+" : "+
     takvim.get(Calendar.MINUTE)+" : "+
     takvim.get(Calendar.SECOND);
     jb.setText(s);
 }

      public static void main(String[] args)
      {
      saatSWF pencere= new saatSWF();
      pencere.addWindowListener(new BasicWindowMonitor());
      pencere.setSize(400,100);
      pencere.setVisible(true);
      }
 }