java.util.Timer就是你要的类。Constructor Summary 
Timer() 
          Creates a new timer. 
Timer(boolean isDaemon) 
          Creates a new timer whose associated thread may be specified to run as a daemon. 
  Method Summary 
 void cancel() 
          Terminates this timer, discarding any currently scheduled tasks. 
 void schedule(TimerTask task, Date time) 
          Schedules the specified task for execution at the specified time. 
 void schedule(TimerTask task, Date firstTime, long period) 
          Schedules the specified task for repeated fixed-delay execution, beginning at the specified time. 
 void schedule(TimerTask task, long delay) 
          Schedules the specified task for execution after the specified delay. 
 void schedule(TimerTask task, long delay, long period) 
          Schedules the specified task for repeated fixed-delay execution, beginning after the specified delay. 
 void scheduleAtFixedRate(TimerTask task, Date firstTime, long period) 
          Schedules the specified task for repeated fixed-rate execution, beginning at the specified time. 
 void scheduleAtFixedRate(TimerTask task, long delay, long period) 
          Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay. 

解决方案 »

  1.   

    呵呵,楼上说的没错
    还有父类就是TimerTask,还有什么TimeThread等等
      

  2.   

    先谢谢各位!我自己使用的是javax.swing.Timer,可是有些问题:我让它间隔一些时间就触发事件,可是却不行。下面是我的部分代码,大家请看看什么问题:
        。。
       javax.swing.Timer mineTimer = new javax.swing.Timer( 5000, this );
       
           public void actionPerformed( ActionEvent event ) {
          if ( event.getActionCommand().equals( "quit" ))
              System.exit(0);
          if ( event.getActionCommand().equals( "smaller" )) {
             //justStart(tt);
             mineTimer.start();
             //System.exit(0);
          }
          if (event.getActionCommand().equals( "larger" )) {
             //System.exit(0);
             mineTimer.stop();
          }
          if (event.getActionCommand().equals( "mineTimer" )) {
          /*
            if (newLabel.getText().equals("100")) newLabel.setText("222");
            if (newLabel.getText().equals("222")) newLabel.setText("100");
            */      }
        }
       编译没有问题,可是运行却不行?请问各位如何解决?谢谢!