宾馆管理系统实例 用Java与sql server 2000来创建一个宾馆管理系统
源代码在线查看: clocklabel.java~2~
package hotel;
import java.awt.*;
import javax.swing.JLabel;
import java.util.*;
import java.text.*;
/**
* Title: 宾馆官理系统
* Description: 第七章实例
* Copyright: Copyright (c) 2006
* Company:
* @author 苏年乐
* @version 1.0
*/
/**
* 计时
*/
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;
}
}