View Single Post
  #2 (permalink)  
Old 07-20-2007, 01:51 PM
JavaBean's Avatar
JavaBean JavaBean is offline
Moderator
 
Join Date: May 2007
Posts: 1,272
JavaBean is on a distinguished road
Quote:
can I utilize threads as runnable only when you press the button?
Yes. Just create the thread in the constructor of your JFrame an call start method when the button pressed!

Quote:
Is there a variable that acts hours,mins,sec accordingly?
Yes, keep the number of seconds remaining in a variable and decrease it every seconds! You can call Thread.sleep(X) method to sleep X number of milliseconds.

You can keep the above variable in your thread and decrease its value and call a method to update the representation. For example representation can be a JLabel and you can call its setText() method in your update method!
Reply With Quote