• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JProgressbar problem

 
david arnold
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2613
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
david arnold
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I see, thank you Rob for the help again !!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic