日历要的不就是当前时间吗?
楼主目的是?
package Example908;
import java.awt.*;
import java.util.*;
import javax.swing.*;
public class JFrameTest extends JFrame implements Runnable {
/**
*苦中乐20060908
*/
private JTextField text;
private Thread clockThread;
public JFrameTest(){
Container contentPane=getContentPane();
text=new JTextField(20);
contentPane.setLayout(new FlowLayout());
contentPane.add(text);
setDefaultCloseOperation(this.EXIT_ON_CLOSE);
setUndecorated(true);
getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
this.setResizable(false);
setTitle("苦中乐--->电子时钟");
this.pack();
this.setMaximizedBounds(null);
setVisible(true);
clockThread=new Thread(this);
clockThread.start();
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new JFrameTest();
}
public void run() {
// TODO Auto-generated method stub
try {
clockThread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
while(true){
Date date=new Date();
text.setText(date.getHours()+":"+date.getMinutes()+":"+date.getSeconds());
}
}
}