简单时钟java程序..docxVIP

  • 0
  • 0
  • 约1.85千字
  • 约 1页
  • 2021-01-20 发布于山东
  • 举报
import java.awt.Container; import java.awt.GridLayout; import java.text.DateFormat; import java.util.Calendar; import java.util.Date; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; class MyThread1 extends JPanel implements Runnable { int h, m, s; JLabel time1 = new JLabel(; public MyThread1( { // 编写子类的构造方法 this.add(time1; } public void run( { // 定义线程体,编写线程代码 while (true { Date now = new Date(; DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG; //显示日期。时间(精确到秒) String str = df.format(now; time1.setText(; time1.setText(str; // 显示时间

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档