• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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]
 
reply
    Bookmark Topic Watch Topic
  • New Topic