//ClockDemo.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package newpackage;
import java.awt.*;
import java.util.*;
import javax.swing.*;
//数字时钟
public class ClockDemo extends JFrame implements Runnable{
Thread clock;
public ClockDemo(){
super("数字时钟");//调用父类构造函数
setFont(new Font("Times New Roman",Font.BOLD,60));//设置时钟的显示字体
start(); //开始进程
setSize(280,100); //设置窗口尺寸
setVisible(true); //窗口可视
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //关闭窗口时退出程序
}
public void start(){ //开始进程
if (clock==null){ //如果进程为空值
clock=new Thread(this); //实例化进程
clock.start(); //开始进程