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.
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.
还有父类就是TimerTask,还有什么TimeThread等等
。。
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");
*/ }
}
编译没有问题,可是运行却不行?请问各位如何解决?谢谢!