// Decompiled by DJ v3.12.12.96 Copyright 2011 Atanas Neshkov  Date: 08/10/2012 8:48:05
// Home Page: http://members.fortunecity.com/neshkov/dj.html http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   Reloj.java

package project;

import java.awt.*;
import java.text.*;
import java.util.*;
import javax.swing.JComponent;
import javax.swing.JTextField;
import javax.swing.text.JTextComponent;

public class Reloj extends JTextField
    implements Runnable
{

    public Reloj()
    {
        clockThread = null;
        zero = 0L;
        dateFormatter = DateFormat.getTimeInstance();
        formatter = new DecimalFormat("00");
        isTimer = false;
        if(clockThread == null)
        {
            clockThread = new Thread(this, "Clock");
            clockThread.start();
        }
        Font f1 = new Font("Arial", 1, 13);
        setFont(f1);
        setEditable(false);
        setEnabled(false);
        setPreferredSize(new Dimension(90, 20));
    }

    public void setZeroNow()
    {
        zero = System.currentTimeMillis();
        dateFormatter = DateFormat.getTimeInstance(3, Locale.UK);
        isTimer = true;
    }

    public void run()
    {
        for(Thread myThread = Thread.currentThread(); clockThread == myThread;)
        {
            GregorianCalendar calendar = new GregorianCalendar();
            secs = calendar.get(13);
            mins = calendar.get(12);
            hours = calendar.get(11);
            setText(formatter.format(hours) + ":" + formatter.format(mins) + ":" + formatter.format(secs));
            invalidate();
            try
            {
                Thread.sleep(1000L);
            }
            catch(InterruptedException e)
            {
                e.printStackTrace();
            }
        }

    }

    protected void finalize()
        throws Throwable
    {
        clockThread = null;
        super.finalize();
    }

    long secs;
    long mins;
    long hours;
    long time;
    private Thread clockThread;
    private long zero;
    DateFormat dateFormatter;
    DecimalFormat formatter;
    private boolean isTimer;
}