• Post Reply Bookmark Topic Watch Topic
  • New Topic

Multiple jFrames, a thread and a progress bar  RSS feed

 
John Devlon
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • 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]
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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="_new" rel="nofollow">webpage

John
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!