Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:出来乍到,请问怎么样把代码放到黑板中 [Re:micsolaris]
shingoyj





发贴: 1
积分: 0
于 2008-10-29 13:16 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
import java.awt.BorderLayout;
import java.awt.Container;
import java.util.Date;
import javax.swing.JButton;
import javax.swing.JFrame;

class MyFrame extends JFrame {
JButton timeButton;

public MyFrame() {
setSize(400, 200);
setEnabled(true);
setTitle("时间表");
Container container = getContentPane();
timeButton = new JButton();
container.add(timeButton, BorderLayout.CENTER);
setVisible(true);

String timeStr;
String year;
String month;
String day;
String hour;
String minute;
String second;
while (true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Date date = new Date();
year = String.valueOf(date.getYear() + 1900);
month = String.valueOf(date.getMonth() + 1);
day = String.valueOf(date.getDate());
hour = String.valueOf(date.getHours());
minute = String.valueOf(date.getMinutes());
second = String.valueOf(date.getSeconds());
timeStr = "现在时刻是:" + year + "年" + month + "月" + day + "日" + " "
+ hour + "时" + minute + "分" + second + "秒";
timeButton.setText(timeStr);
}
}
}

public class TimeTest {
public static void main(String[] args) {
MyFrame myFrame = new MyFrame();
myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}




我有一点感想和初学者们同享(原创)

话题树型展开
人气 标题 作者 字数 发贴时间
11290 出来乍到,请问怎么样把代码放到黑板中 micsolaris 30 2008-09-12 01:06
8160 Re:出来乍到,请问怎么样把代码放到黑板中 JiafanZhou 77 2008-09-12 16:18
8362 Re:出来乍到,请问怎么样把代码放到黑板中 xuxiaolei 63 2008-09-12 16:20
8178 Re:出来乍到,请问怎么样把代码放到黑板中 jancyu2008 17 2008-09-15 00:11
8569 Re:出来乍到,请问怎么样把代码放到黑板中 micsolaris 9 2008-09-15 02:28
8664 Re:出来乍到,请问怎么样把代码放到黑板中 shingoyj 1467 2008-10-29 13:16

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923