Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help, about using Timer

Status
Not open for further replies.

tommabear

Programmer
Sep 15, 2003
1
AU
I am doing a program using Timer class. I start the Timer in a function.
When the function is called directly in the program, it works fine.( The Timer can send ActionEvent every delay time, and call ActionPerformed function to do the job.)
But when I put the function in an ActionPerformed function of another ActionListener added on a MenuItem, after that MenuItem is clicked, the Timer's ActionListener wont get any event anymore. Furthermore, other items listening an ActionEvent cant get event as well.(The program doesnt go into ActionPerformed function)
Does anyone know what is wrong with it?
 
java.util.Timer works with java.util.TimerTask

Timer timer=new Timer();
timer.schedule(new TimerTask(){
public void run(){
...whatever function you want performed;
}}),0,10000);
timer.cancel();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top