wood burning stoves
The moose likes Beginning Java and the fly likes How to stop a timer? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to stop a timer?" Watch "How to stop a timer?" New topic

How to stop a timer?

Ankit Kashyap

Joined: Jan 08, 2013
Posts: 13
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.

AAL... IZZ... WELLL...
Steve Luke

Joined: Jan 28, 2003
Posts: 4181

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

Joined: Jan 08, 2013
Posts: 13
Yay, thanks now it works properly after making ' t.setRepeats(false); '.
I agree. Here's the link: http://aspose.com/file-tools
subject: How to stop a timer?
It's not a secret anymore!