----------------解决方案--------------------------------------------------------
日历要的不就是当前时间吗?
楼主目的是?
----------------解决方案--------------------------------------------------------
我懂他的意思了 是不是要时间在不停的动?就象钟一样 有个秒在不停的转 用线程就可以实现了啊
----------------解决方案--------------------------------------------------------
是啊,请问你们会吗
----------------解决方案--------------------------------------------------------
水影说的没错 用线程实现
----------------解决方案--------------------------------------------------------
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());
}
}
}
----------------解决方案--------------------------------------------------------