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
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:
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: