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

 class saat2 extends Thread
 {
 JFrame a;
 public saat2(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 C14E7 extends JFrame implements Runnable
 {
 JLabel jb;
 Font F;
 Date D;
 saat2 r;
 GregorianCalendar calender;
 Thread runner;

 public C14E7()
 {
 super("Digital saat implements Runnable Thread");
 Container cc=getContentPane();
 jb=new JLabel("");
 F=new Font("TimesRoman",Font.BOLD,24);
 jb.setFont(F);
 // Türkiye standart time + 1 hour( 3 hours advanced from Greenwitch)
 String[] ids = TimeZone.getAvailableIDs(+3 * 60 * 60 * 1000);
 SimpleTimeZone pdt = new SimpleTimeZone(+3 * 60 * 60 * 1000, ids[0]);
 calender=new GregorianCalendar(pdt);
 D=new Date();
 calender.setTime(D);
 r=new saat2(this);
 cc.add(jb);
 r.start();
 }

    public void start()
    {
        if(runner==null)
        {
            runner=new Thread(this);
            runner.start();
        }
    }

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


    public void paint(Graphics g)
    {
    D=new Date();
    calender.setTime(D);
    String s="      ["+
    calender.get(Calendar.DATE) +" / "+
    calender.get(Calendar.MONTH)+" / "+
    calender.get(Calendar.YEAR) +" ] "+
    calender.get(Calendar.HOUR_OF_DAY)+" : "+
    calender.get(Calendar.MINUTE)+" : "+
    calender.get(Calendar.SECOND);
    jb.setText(s);
    }
    public static void main(String s[])
    {
        C14E7 f= new C14E7();
        f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        f.setSize(400,100);
        f.setVisible(true);        
    }
 }
