File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes JProgressBar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "JProgressBar" Watch "JProgressBar" New topic
Author

JProgressBar

Ebraheem Salameh
Greenhorn

Joined: Mar 02, 2006
Posts: 3
Cheers every one!

I am at the final stages of my assignment.. thanks to you all you have been of a lot of help although this is my first post here.

I have a tiny big questino..

I would like to add a progress indicator in my gui to appear as a job is being done, this can be useful when the aplication is trying to connect or anything that takes time is executed.

I have the following class:


Before starting the connection for example, I would say:

PromptUser.showWaitMessage();

and once I finish I would say:

PromptUser.hideWaitMessage();

The probelem is that this does not always waork, some times the progress bar appears after the task is finished.

I have read in some forums that this code should be on a thread other than the main thread, however I have just always failed in making it work correctly

Any thoughts???

Waiting...
Roy Mallard
Ranch Hand

Joined: Jul 14, 2005
Posts: 53
The probelem is that this does not always waork, some times the progress bar appears after the task is finished.


Maybe you could have your task dispose of the progress bar when the task is finished? That would prevent it popping up when it is too late...

It sounds like you are tying up the main thread with your confirm() method.
Your confirm() method won't return until your dialog box is closed. It might be a good idea to provide a method to add an actionListener to the Cancel button and just call setVisible(true) on your progress dialog box.


SCJP 1.4<br />SCJD
Ebraheem Salameh
Greenhorn

Joined: Mar 02, 2006
Posts: 3
Thanks Roy for the reply...

Perhapse I did not make myself clear...
The confirm() and handleException() methods have nothing to do with the problem. It is only that when I do:

PromptUser.ShowWaitMessage();
//do some heavy work here
PromptUser.hideWaitMessage();

The progress bar does not show (or maybe is not refreshed) until the heavy work is done.
There must be a threaded solution somehow... but I'm still
Ebraheem Salameh
Greenhorn

Joined: Mar 02, 2006
Posts: 3
If no one helps soon then My head will break.... cuz I'm still
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JProgressBar
 
Similar Threads
closing a JDialog with a button
JProgress bar problem
What is the best way to implement this?
gui and thread
JProgressBar - Please Help