JAVA計時器(秒表)程序代碼(最新整理)_第1頁
JAVA計時器(秒表)程序代碼(最新整理)_第2頁
JAVA計時器(秒表)程序代碼(最新整理)_第3頁
已閱讀5頁,還剩4頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)

文檔簡介

1、java 計時器(秒表)功能:能實現(xiàn)計時,暫停,清零,記錄功能。如下圖:程序運行狀態(tài):源代碼: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; /開始,暫停控制開關(guān)); /開始按鈕button2.addactionlistener(new actionlistener() public void actionperformed(actionevent e) on=0;); /暫停按鈕button3.addactionlistener(new actionlistener() public void actionperformed(actionevent e) r=1; /清零控制開關(guān)); /清零按鈕button4.addactionlistener(new act

6、ionlistener() public void actionperformed(actionevent e)count=1; /記錄控制開關(guān)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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論