Results 1 to 9 of 9
- 04-07-2010, 10:18 PM #1
JProgress Bar - How to wait before the next .setValue() is called
Using a progress bar on the program loadup screen for my final school project.
I've run into an issue however.
How do I make the system wait before I update the progress bar?
I've tried the .wait() method, inside a try catch but always get a run-time error.
by the way: this is a 'fake' progress bar. The program it's self is a realitively small program and will use little system resources. i just wanted to add a little 'touch' for some pezazz.
Last edited by Unsub; 04-07-2010 at 10:20 PM.
- 04-07-2010, 10:37 PM #2Member
- Join Date
- Apr 2010
- Rep Power
Use a thread.sleep( long ms)
where ms = how long in milliseconds you want it to wait for
- 04-07-2010, 11:03 PM #3
all that is doing is delaying the display of the entire screen until the specified ms has passed.
i'm lookin to have it display everything within the frame and then delay the updating of just the progress bar
Thread.sleep is a very bad idea as it will just put the EDT, the main thread that runs Swing -- and by doing this, your whole program -- to sleep. Perhaps you want to use either a Swing Timer (my preference) or a background timer.
- 04-08-2010, 03:42 AM #5
- 04-08-2010, 09:34 PM #7
There are two Timers that are commonly used, the java.util.Timer and the javax.swing.Timer. Since this is Swing, and you want your timer actions called on Swing's main event thread, use the javax.swing.Timer, or Swing Timer. Much luck!
- 04-08-2010, 10:14 PM #9
- By Mkaveli in forum Threads and SynchronizationReplies: 2Last Post: 03-30-2010, 11:58 AM
- By flok in forum AWT / SwingReplies: 8Last Post: 10-19-2009, 04:45 PM
- By denis in forum Threads and SynchronizationReplies: 13Last Post: 04-22-2009, 08:28 AM
- By jiexx in forum Threads and SynchronizationReplies: 1Last Post: 03-19-2009, 06:26 PM
- By Java Tip in forum java.langReplies: 0Last Post: 04-09-2008, 06:32 PM