- 1、本文档共9页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
java时钟程序(Java clock program)
java时钟程序(Java clock program)
import java.awt. ';
import java.awt.event. ';
import java.awt.geom. ';
import java.text.simpledateformat.
import java.util.date.
import javax.swing.timer.
public class shizhong {
public static void main (string [] args) {
win = new frame (frame).
label label = new label ().
win.add (new clock (), borderlayout.center).
win.add (label, borderlayout.south).
win.setvisible (true).
win.setsize (246280).
win.validate ().
win.addwindowlistener (
new windowadapter () {
public void windowclosing (windowevent (e)
system.exit 关闭按钮响应 (0); / * * /
}
}
);
new thread, new testthread (label).start ().
}
}
class testthread implements runnable {
label label.
testthread label (label)
this.label = label;
}
public void run () {
while (true) {
label.settext (new simpledateformat (hh: mm: ss).format (new date ());
try {
thread.sleep (1000).
} catch (interruptedexception (e)
e.printstacktrace (); / * printstacktrace () 方法的意思是: 在命令行打印异常信息在程序中出错的位置及原因 * /
捕获异常} / * * /
}
}
}
class clock extends canvas implements actionlistener {/ * canvas 组件表示屏幕上一个空白矩形区域, 应用程序可以在该区域内绘图, 或者可以从该区域捕获用户的输入事件. * /
/ * *
*
* /
private static final long serialversionuid = 1;
date;
timer secondtime.
int hour, munite, second.
line2d secondline, muniteline, hourline line2d 表示; / * (x, y) 坐标空间内的线段 * /
int a, b, c,.
[] = new double double pointsx [60].
pointsy [] = new double [60].
pointmx [] = new double [60].
pointmy [] = new double [60].
pointhx [] = new double [60].
pointhy [] = new double [60].
clock () {
secondtime = new timer (1000 a);
pointsx [0] = 0.
pointsy [0] = 100;
pointmx [0] = 0.
pointmy [0] = - 90.
pointhx [0] = 0.
pointhy [0] = 70.
double adgle = 6 * math.pi / 180;
for (int i = 0; i < 59; i + +) {
pointsx [i + 1] = [i] * math.cos pointsx (adgle) -math.sin (adgle) pointsy [d].
pointsy [i + 1] = [i] * math.cos pointsy (adgle) + math.sin (adgle) pointsx [d].
pointmx [i + 1] = [i] * math.cos pointmx (adgle) -math.sin (adgle) pointmy [d].
pointmy [i + 1] = [i] * math.cos pointmy
您可能关注的文档
- IECP — an approach for integrated environmental and cost evaluation of process design alternatives and its application to evaluate different NOx prevention technologies in a 125 MW thermal power plant.pdf
- Insurance companies increase premium for hydropower plants:保险公司提高保费的水电厂.docx
- Intra-pancreatic Distal Bile Duct Carcinoma is Morphologically, Genetically, and Clinically Distinct from Pancreatic Duc.Intra-pancreatic远端胆管癌形态,从胰腺导管腺.pdf
- hiyou产品App端需求文档v1.0-2013-4-15(最终定稿) - 副本.pdf
- Investment Policy - Griffith University:投资策略-格里菲斯大学.docx
- IPO项目尽职调查文件清单.doc
- java俄罗斯方块报告 《Java程序设计》实训报告——俄罗斯方块.doc
- java日历时钟小程序.doc
- JAVA俄罗斯方块实训报告.doc.doc
- java程序设计-时钟.doc
文档评论(0)