java全屏时钟代码 java图形时钟-成都快上网建站

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图形时钟
URL网址:http://kswjz.com/article/dsphijh.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流