JAVA计时器(秒表)程序代码(最新整理)_第1页
JAVA计时器(秒表)程序代码(最新整理)_第2页
JAVA计时器(秒表)程序代码(最新整理)_第3页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论