RT
求解答...
觉得每秒读当前时间好浪费...
有没有像按钮监听器那样的,触发性质的?

解决方案 »

  1.   

    开始的时候读取当前时间,然后sleep(1000),更新显示
      

  2.   


    public class TimerTest { public static void main(String[] args) throws InterruptedException {
    new TimerTest().execute();

    }

    public void execute(){
    java.util.Timer timer = new java.util.Timer();
    MyTimerTask m = new MyTimerTask();
    java.util.Date date = new java.util.Date();
    timer.schedule(m, date, 1000*60);
    }

    }class MyTimerTask extends java.util.TimerTask{
    public void run(){
    System.out.println("this is a test!  AT: " + new java.util.Date());
    }
    }把这个代码改改就OK了