• Post Reply Bookmark Topic Watch Topic
  • New Topic

JProgressBar

 
selvi shankar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a Login Frame and once the user logs in it opens an application Frame.
I would like to include a Progress Bar to show the loading process of the application Frame.
I read the sun's tutorial on JProgressBar but I don't have a clue how to do it for the Frame..
Any ideas?
Thanks,
Selvi
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's two things. First, you need to have some sort of interface between the two frames so the main frame can update the login frame. You can do this by implementing java.util.Observer/Observable, making the login frame a "child" of the main frame and providing a status update method on the login frame, or do like I did below, aggregate the two frames in a controller class. Next, you need to be aware that you can't use the Swing event thread to perform the initalization of your main thread. That's the thread that invokes actionPerformed() when the login frame's button is pressed, but it's also the thread that does the updates to the JProgressBar's image. You need to create some worker thread to perform those tasks (or invoke the initalization methods on your various objects, however you implement it). Here's a simple example:

[ January 14, 2004: Message edited by: Joe Ess ]
 
Brian Pipa
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That code doesn't compile for me. I get a

excpetion.
if I catch the exception, it runs but when i press login I get:

Brian
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Brian Pipa:
That code doesn't compile for me.

My bad. I originaly had a Thread.sleep() in the run() method and changed it to use wait() and notify() just before posting. Guess my compile window in JEdit was too small to see the compile error. . .
Nonetheless, to fix the errors, replace the wait() and notify() calls to the following:

I apologize for any inconvenience. . .
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!