import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Date;
public class Test1 {
public static void main(String[] args){
Watch w=new Watch();
Thread t=new Thread(w);
t.start();
w.setVisible(true);
}
}
class Watch extends JFrame implements Runnable{
JLabel label1;
//JLabel label2;
Container cp;
//Calendar c=Calendar.getInstance();
Date mydate;
public Watch(){
// label1.setFont(new Font("TimesRoman",Font.BOLD,16));
label1=new JLabel("当前的时间为:");
mydate=new Date();
//label2=new JLabel("");
cp=getContentPane();
cp.setLayout(new BorderLayout());
cp.add(label1,"North");
setSize(200,200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void paint(Graphics g){
//g.setFont(new Font("TimesRoman",Font.BOLD,16"));
g.setColor(Color.magenta);
g.drawString(mydate.toString(),10,100);
}
public void run(){
while(true){
repaint();
try{
Thread.sleep(1000);
}catch(Exception e){System.out.print(e.getMessage());}
}
}
}