java全屏时钟代码 java图形时钟

求用java语言设计一个动态时钟,每秒刷新一次

package com.kaylves;

成都创新互联公司长期为成百上千客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为辽宁企业提供专业的网站建设、网站制作辽宁网站改版等技术服务。拥有10余年丰富建站经验和众多成功案例,为您定制开发。

import java.text.SimpleDateFormat;

import java.util.Date;

import javax.swing.JFrame;

import javax.swing.JLabel;

public class Clock {

public static void main(String[] args) throws InterruptedException {

JFrame f = new JFrame();

Timer timer = new Timer();

Thread th=new Thread(timer);

th.start();

JLabel time = new JLabel();

f.add(time);

f.setVisible(true);

f.pack();

while(true){

time.setText(timer.getCurrentTime());

}

}

}

class Timer implements Runnable {

private String currentTime;

public String getCurrentTime() {

Date d = new Date();

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

currentTime = sdf.format(d);

return currentTime;

}

public void run() {

try {

Thread.sleep(1000);

getCurrentTime();

} catch (InterruptedException e) {

e.printStackTrace();

}

}

}

完成给核液汪改仔分埋哪


网站栏目:java全屏时钟代码 java图形时钟
文章来源:http://lszwz.com/article/dsphijh.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款