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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JProgressbar problem" Watch "JProgressbar problem" New topic

JProgressbar problem

david arnold
Ranch Hand

Joined: Apr 10, 2009
Posts: 133

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?

Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2152
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?

Rob Spoor

Joined: Oct 27, 2005
Posts: 19649

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.

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 !!
Don't get me started about those stupid light bulbs.
subject: JProgressbar problem
Similar Threads
Swing - Problem with JProgress indefenite state
Thread Concept
Basic invokeLater question
JProgressBar - Please Help
JProgressBar in Napkin look and feel is not working