Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

how to use timer to delay two actions?

 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I created a swing app and there are two buttons on the interface. When use clicks a button it will carry out some series of action, I want to use a timer object to control create a some seconds delay after each action happen because i have a run time object within my code.
My program basically do the following stuff:
Generate button : generate swing script code and save into a x.java file.
Compile Button: executing a .bat file to compile it into a x.class, and then delete the .bat file after compiling. Usually it will takes a few second to run the bat file within the app. Sometimes the bat file is being deleted before compiling.
My bat file is has only one line of code "javac xxx.java".
I hope i explained it clear enough. Can anyone give some ideas of how use a timer to delay two actions?
Thanks! I appreciate for your response!
Mindy
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are using Threads you can just do

Or are you looking to actually use a Timer object?
 
Mindy Wu
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Cindy! I did use Thread but i forgot to use the sleep() method. It is working fine now. Thank you for your response.
Mindy
 
Life just hasn't been the same since the volcano erupted and now the air is full of tiny ads.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic