版權(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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 山東省濟寧市金鄉(xiāng)縣2023-2024學(xué)年六年級下學(xué)期期末考試英語試卷
- 24.1.4 圓周角 人教版數(shù)學(xué)九年級上冊堂堂練(含答案)
- 陜西省西安國際港務(wù)區(qū)鐵一中陸港初級中學(xué)2024-2025學(xué)年八年級上學(xué)期第一次月考數(shù)學(xué)試題(無答案)
- 人力資源預(yù)算編制與控制的最佳實踐案例分析
- 股權(quán)結(jié)構(gòu)對公司財務(wù)預(yù)測準(zhǔn)確性的提升作用研究
- 江蘇省南京市江寧區(qū)湖熟片達(dá)標(biāo)名校2024屆中考數(shù)學(xué)最后一模試卷含解析
- 2023年天水武山縣人社局招聘城鎮(zhèn)公益性崗位工作人員考試試題及答案
- 2023年南通市崇川區(qū)招聘園區(qū)專業(yè)人才考試試題及答案
- 2023年廣東珠海高新技術(shù)產(chǎn)業(yè)開發(fā)區(qū)綜合治理局招聘職員考試試題及答案
- 2023年都江堰市教育局所屬市教師管理中心社會引進筆試真題
- 足浴店管理方案
- 初中教育中的家校合作與共育模式
- 液態(tài)成形(砂型鑄造)
- 國家開放大學(xué)2023年7月期末統(tǒng)一試《11475藥物治療學(xué)(本)》試題及答案-開放本科
- 消防安全隱患排查投標(biāo)方案(技術(shù)標(biāo))
- 宮頸機能不全指南
- 《外國人來華工作許可證》聘用合同或任職證明正規(guī)范本(通用版)
- 雙層壓型鋼板復(fù)合保溫屋面施工方案
- 老年人生活自理能力評估標(biāo)準(zhǔn)
- 安全帽檢測報告及原始記錄
評論
0/150
提交評論