?? clocklabel.java
字號:
package hotel2;import java.awt.*;import javax.swing.JLabel;import java.util.*;import java.text.*; public class Clocklabel extends JLabel implements Runnable{ private Thread clockthread=null; public Clocklabel() { if(clockthread==null) { clockthread=new Thread(this,"clock"); clockthread.start(); } } public void run() { while(true) { Calendar cal=Calendar.getInstance(); Date date=cal.getTime(); DateFormat dateformatter=DateFormat.getTimeInstance(); this.setText(dateformatter.format(date)); try{ Thread.sleep(1000); } catch(Exception e){} } } public Thread getClockthread() { return clockthread; }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -