aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JProgressbar problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JProgressbar problem" Watch "JProgressbar problem" New topic
Author

JProgressbar problem

david arnold
Ranch Hand

Joined: Apr 10, 2009
Posts: 133
Hi,

I tried to animate the jprogressbar in a method doUploadAction(), then start a thread to upload a image, and stop the jprogressbar indeterminate animation after the thread finish, but it did not work. The progress bar did not do anything at all.


What is wrong with it? Do I need to start a new thread for the progressbar and do the upload in current thread?

Thanks.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2202
    
    7
Read the JProgressBar API and follow the link to the Swing tutorial on "How to Monitor Progress" for a working example.
david arnold
Ranch Hand

Joined: Apr 10, 2009
Posts: 133
Thank you Rob. I already read that. The progressbar is in a pane, not a pop up dialog which will be used by progressMonitor. Also, since i am using java 1.5, there is not SwingWorker which is new for java 1.6 and I can not use Task. So my way will not work? What is the problem with it?

Thanks.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

Why are you creating an anonymous Runnable, then call its run() method? That doesn't create a thread or anything; you might as well just place the contents of the run() method there.

If you cannot use SwingWorker (I suggest you upgrade to Java 6; Java 5.0 is getting quite old already!) you should use a regular thread, and do all interactions to the GUI using EventQueue.invokeLater or EventQueue.invokeAndWait.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
david arnold
Ranch Hand

Joined: Apr 10, 2009
Posts: 133

I see, thank you Rob for the help again !!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JProgressbar problem