Win a copy of Java Challengers this week in the Java in General 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:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

JProgressBar

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 9625
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 9625
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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. . .
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic