Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to stop a timer?

 
Ankit Kashyap
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I made an improvement! Now after the winter breaks, i successfully made and ran a timer(disposed a JFrame). But, i have no idea how to stop the timer.
I don't know where to put the line " t.stop(); ".
The code is attached below.

When i run my application, it works perfectly till home.
Then, if i click any button on 'home'(open a new frame of the program), or the focus of home is lost by any means, home comes back into focus after 3.75 seconds virtually disabling the rest of the program or any other program.


justjoking is a button used to display the frame to be disposed.
intro is the frame to be disposed.
home is an another frame which shows up when intro is disposed.

Thank you.
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked at the API for the javax.swing.Timer? There is a method in there that will be most useful to call before you start the timer.
 
Ankit Kashyap
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yay, thanks now it works properly after making ' t.setRepeats(false); '.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic