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.
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).
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]