import javax.swing.JLabel;
import java.util.Date;
public class Time extends JFrame implements Runnable {
private JLabel timeLabel=null;
private Date d=null;
public static void main(String args[]) {
new Time():
}
public Time() {
this.setTitle("多线程");
this.setSize(400,300):
this.setVisible(true);
this.setDefaultOperationClose(JFrame.EXIT_ON_CLOSE);
timeLabel=new JLabel();
this.getContentPane.add(timeLabel,BorderLayout.NORTH);
Thread t=new Thread(this);
t.start();
}
public void run() {
while (true) {
d=new Date();
timeLabel.setText(d.toString());
}
}
}
追问嗯 加点注释吧
本回答被提问者采纳