• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to stop a timer?

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yay, thanks now it works properly after making ' t.setRepeats(false); '.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic