


版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- DB31/T 583-2012社区公益服务项目绩效评估导则
- DB31/ 897-2015预拌砂浆单位产品综合能源消耗限额
- 2025电缆采购合同格式范本
- 谷物磨制在粮食加工产业促进农产品加工副产物利用的研究考核试卷
- 玩具企业的品牌传播与公关策略考核试卷
- 深海油气钻探设备故障树分析考核试卷
- 2024年竹材采伐产品资金申请报告代可行性研究报告
- 2024年纸卷包装输送系统资金筹措计划书代可行性研究报告
- 高端紧缺人才引进与技术服务合作协议
- 影视作品音乐版权授权与版权保护及收益分成及广告合作合同
- 22S803 圆形钢筋混凝土蓄水池
- 电信运营商社会渠道管理报告
- 2022-2023学年宁夏回族石嘴山市大武口区小学六年级第二学期小升初数学试卷含答案
- 经济与社会:如何用决策思维洞察生活学习通课后章节答案期末考试题库2023年
- 绿化设备车辆管理维护方案
- 2023汽车智能座舱分级与综合评价白皮书
- 职业暴露针刺伤应急预案演练脚本-
- 外科学教学课件:肠梗阻阑尾炎
- 国开电大 可编程控制器应用实训 形考任务4实训报告
- 中国神华能源股份有限公司大柳塔煤矿矿山地质环境保护与土地复垦方案
- 抗菌药物使用分级授权表
评论
0/150
提交评论