This week's giveaway is in the Java in General forum.
We're giving away four copies of Java Challengers and have Rafael del Nero on-line!
See this thread for details.
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 and Determining Task Length

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I created a nice little splash screen with a JProgressBar at the bottom. Looks nice. I am simulating a long running task for the progress bar and obviously have to use a static length for the time for testing.

Now I want to change it so that it's based on the initialization of my application. There are a few things I do which take a bit of time.

confirm DB presence and connection
load resources (images, sounds, etc)
load properties and configuration for current client

So how would I calculated how long each of these processes will take so that I can update my progress bar accordingly? Is this even possible?

Another possibility is I could remove the progress bar and just have a JLabel with updated value of what part the system is on. But I kind of like the look of the progress bar.
 
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Confirming the presence of the database would be hard to quantify. As to the rest... Do you know how many resources there are to load? and how many properties you need to load? you could update the progress bar as one item is loaded (making the progress bar show a percentage complete).
 
author
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gregg,

I did something similar in an application a while back. I agree with the other post that getting ganular levels from your DB connection process might be difficult. The only steps that quickly come to mind are JDBC driver class loading time and connection time. Might I suggest having each of thse load up sections being observable in terms of progress? You can then funnel these smaller progress indicators into a larger overall progress indicator. Eclipse does something like this with SubMonitors. So the overall monitor might define 4 steps. A sub monitor might have 25 steps. Their code calculates the percentage on the fly based off the position of both monitors. So if the sub monitor was at 15 and is the second part of the overall monitor you have 40% done.

Scott Delap
[url=http://www.clientjava.com]ClientJava.com[url]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic