package csdn.lesson2;
import java.util.*;
import javax.swing.*;
public class Clock {
public static void main(String[] args) {
JFrame jf = new JFrame("Clock");
JLabel jl = new JLabel("Clock");
jl.setHorizontalAlignment(JLabel.CENTER);
jf.add(jl,"Center");
jf.setBounds(500,300,200,100);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setVisible(true);
Thread t = new MyThread(jl);
t.start();
}
}
class MyThread extends Thread{
private JLabel jl;
public MyThread(JLabel jl){
this.jl = jl;
}
public void run(){
while(true){
jl.setText(this.getTime());
try{
Thread.sleep(1000);
}catch(InterruptedException e){
e.pri