//File testTimer.java
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.JOptionPane;
public class testTimer {
private static int count =0;
public static void main(String[] args) throws Exception {
testTimer t = new testTimer();
t.execute();
}
void execute() throws Exception {
int initialDelay = 1000; // start after 1 seconds
int period = 2000; // repeat every 2 seconds
Timer timer = new Timer();
System.out.println(” Timer set”);
timer.scheduleAtFixedRate(new TimerTask() {
public void run() {
JOptionPane.showMessageDialog(null,count++);
}
}, initialDelay, period);
}
}
Filed under: Uncategorized