Win a copy of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) this week in the OCPJP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

JProgressbar problem

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 3267
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22656
126
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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