This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to stop a timer?" Watch "How to stop a timer?" New topic
Author

How to stop a timer?

Ankit Kashyap
Greenhorn

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
Bartender

Joined: Jan 28, 2003
Posts: 4165
    
  21

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.


Steve
Ankit Kashyap
Greenhorn

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?
 
Similar Threads
closing Simple message box
Swing animation with Start and Stop
slowing down movement in an applet.... doesn't have anything to do with the applet.
JLabel setText problem...
Progress Bar while using Streaming