package ThreadPro;
import java.awt.*;
import java.util.*;
import java.awt.event.*;
import java.text.SimpleDateFormat;
class time extends Frame implements Runnable{
public Label tm=new Label();
public Panel p1=new Panel();
public void run() {
while(true)
{
this.setTitle("时钟");
this.setBackground(Color.GREEN);
this.setResizable(true);
this.setAlwaysOnTop(true);
this.setBounds(200, 200, 300, 300);
Date Now = new Date();
SimpleDateFormat t = new SimpleDateFormat ("HH:mm:ss");
tm.setText(t.format(Now));
p1.add(tm);
this.add(p1);
this.setVisible(true);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
}
}
public class Clock {
public static void main(String[] args) {
time f1=new time();
Thread t1 = new Thread(f1);
t1.start();
}
}
