• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Multiple jFrames, a thread and a progress bar

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm struggling with a small project.

I have 2 jFrames. The first frame has a button that...
- Display's the second frame containing a progressbar
- Starts a heavy processing thread

I need to update the progressbar on the second jFrame, from a thread started on the first jFrame.

I have 2 problems:
- How do I update the progressbar?
- When the button is clicked, an empty second frame is displayed with no controles. The controles are only rendered/shown, after the large thread process is finisshed...

I've attached to this post a small screenshot, showing the main idea ...




Source code:

Button action on the first frame:




The code of the thread class


Second jFrame:



Does anyone have any idea's ?

Thanks

John






example.jpg
[Thumbnail for example.jpg]
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you not read Oracle's tutorial about JProgressBar? I'm sure it contains examples of how to use the component. In case you haven't, it's here: How to Use Progress Bars.
 
John Devlon
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Hi Paul,

Thank you for your respons. Yes, I did. All examples on the page mentioned, are using a progress bar on the same swing frame, or using the progress monitor solutions, which is a default popup solution.
Eventually, I would like to use multiple progress bars on a second jFrame, triggerd from a thread launched on the first jFrame (see attachment).

Any help would be great ...

John
example2.jpg
[Thumbnail for example2.jpg]
 
John Devlon
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Eureka !!!

I found the solution ... The solution is the use of the Swingworker class... For those people having the same problem, I post my code below ...

Start button event code on the main/first jFrame


Processing class ...



The main methodes on the second jFrame...



This video was very helpfull...
http://www.caveofprogramming.com/frontpage/youtube/java-multithreading/java-multithreading-swing-swingworker-part-15/" target="_blank" rel="nofollow">webpage

John
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic