package Clock;
import javax.swing.*;
import java.awt.*;
import java.util.Date;
public class ETClock extends JFrame{
public ETClock() throws InterruptedException {
JFrame jFrame = new JFrame();
JLabel label1 = new JLabel();
label1.setText((new Date()).toString());
label1.setFont(new Font("宋体", Font.BOLD, 50));
label1.setForeground(Color.blue);
this.add(label1);
this.pack();
this.setVisible(true);
while(true) {
Thread.sleep(1000);
label1.setText((new Date().toString()));
}
}
public static void main(String[] args) throws InterruptedException {
ETClock clock = new ETClock();
clock.setVisible(true);
}
}
实现效果