


版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、java 计时器(秒表)功能:能实现计时,暂停,清零,记录功能。如下图:程序运行状态:源代码:import javax.swing.*; import java.awt.*; import java.awt.event.*; public class test public static void main(string args)new window(计时器);class window extends jframeint on=0,i=0,j=0,k=0,count=0,num=1,r=0;jbutton button1,button2,button3,button4,button5; jt
2、extfield file1,file2,file3;jtextarea file; flowlayout flow; string a,b,c; window(string name)file1=new jtextfield(2); file2=new jtextfield(2); file3=new jtextfield(2); file1.seteditable(false); file2.seteditable(false); file3.seteditable(false); file=new jtextarea(10,8); file.seteditable(false); but
3、ton1=new jbutton(开始);button2=new jbutton(暂停);button3=new jbutton(清零); button4=new jbutton(记录);button5=new jbutton(清空记录); flow=new flowlayout(); flow.setalignment(flowlayout.left); flow.sethgap(20);flow.setvgap(10); settitle(name); setsize(210,400); setlayout(flow); add(file1);add(new jlabel(:); add(
4、file2);add(new jlabel(:); add(file3); add(button1); add(button2); add(button3); add(button4); add(button5); add(file); setvisible(true);setdefaultcloseoperation(exit_on_close); file1.settext(0);file2.settext(0);file3.settext(0); validate();button1.addactionlistener(new actionlistener() public void a
5、ctionperformed(actionevent e) on=1; /开始,暂停控制开关); /开始按钮button2.addactionlistener(new actionlistener() public void actionperformed(actionevent e) on=0;); /暂停按钮button3.addactionlistener(new actionlistener() public void actionperformed(actionevent e) r=1; /清零控制开关); /清零按钮button4.addactionlistener(new act
6、ionlistener() public void actionperformed(actionevent e)count=1; /记录控制开关a=string.valueof(i); b=string.valueof(j); c=string.valueof(k);); /记录按钮button5.addactionlistener(new actionlistener() public void actionperformed(actionevent e)file.settext(); num=1;); /清除记录按钮while(true)validate();if(on=1) /开始或暂停
7、判断file1.settext(string.valueof(i); file2.settext(string.valueof(j); file3.settext(string.valueof(k); if(k=99)k=-1; j+;if(j=60)k=0; j=0; i+;if(i=24)i=0; j=0; k=0;trythread.sleep(10);catch(exception e) k+;if(count=1)/记录判断file.append(string.valueof(num); file.append(. ); file.append(a); file.append(:);
8、 file.append(b); file.append(:); file.append(c); file.append(n);num+; count=0;if(r=1)/清零判断i=j=k=0; file1.settext(string.valueof(i); file2.settext(string.valueof(j); file3.settext(string.valueof(k);r=0;“”“”at the end, xiao bian gives you a passage. minand once said, people who learn to learn are very
9、 happy people. in every wonderful life, learning is an eternal theme. as a professional clerical and teaching position, i understand the importance of continuous learning, life is diligent, nothing can be gained, only continuous learning can achieve better self. only by constantly learning and mastering the latest relevant knowledge, can employees from all walks of life keep up with the pace of enterprise development and innovate to meet the needs of the
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 防火灾安全教育教学课件
- 高二高中家长会课件
- 2025年公共事业技能鉴定考试-工会系统考试历年参考题库含答案解析(5卷一百题单选合辑)
- 2025年住院医师规范培训(各省)-江苏住院医师中医内科历年参考题库含答案解析(5卷一百题单选合辑)
- 2025贵州兴晔劳务有限责任公司招聘59人笔试历年参考题库附带答案详解
- 黄石二中2024高三数学试卷
- 兰州高中高三数学试卷
- 2025年休闲农业与乡村旅游市场潜力及投资前景研究报告
- 2022年霍林郭勒市五年级语文第三单元考试试卷
- 2022年根河市三年级语文第三单元考试试卷
- 2030年全球甲烷评估基准线报告
- TSG-T7001-2023电梯监督检验和定期检验规则宣贯解读
- 2024年西安市安居建设管理集团有限公司招聘笔试冲刺题(带答案解析)
- 河南省城市生命线安全工程建设指引V1
- 新品上市引爆计划
- 运维管理安全需求分析
- 人才发展(培训课件)
- 游资操盘手法与实录
- 肘关节后脱位的健康宣教
- 纺织行业市场调研及授信指引
- 数控机械加工中的实时测量方案
评论
0/150
提交评论