• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JProgressBar

 
Ebraheem Salameh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ebraheem Salameh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If no one helps soon then My head will break.... cuz I'm still
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic