up previous next contents
Next: Closing/destroying the splash screen Up: How to create and Previous: Initializing the splash screen   Contents

Updating the progress bar

In a real world application we would next start initializing things as our application starts up. Unfortunately for my little demo here the only thing I can do is simulate that, but hopefully you'll get enough from this demo that you'll be able to apply it to your applications. Your calls to the splash screen class will be the same, but your calls won't be from within a nice little for loop like my example.

Here's the code I use in my SplashScreenMain class that simulates the calls you'll be making.

  for (int i = 0; i <= 100; i++)
  {
    for (long j=0; j<50000; ++j)
    {
      String poop = " " + (j + i);
    }
    // run either of these two -- but not both
    screen.setProgress("Yo " + i, i);  // progress bar with a message
    //screen.setProgress(i);           // progress bar with no message
  }

This contrived for loop takes a little while to run, which is the whole purpose of my demo. Nothing in the for loop really matters, except for the screen.setProgress method calls. This is where I'm updating the splash screen's progress bar. In the example that is not commented out I'm passing both a message and a value to the progress bar. This results in a progress bar that looks like this:

Figure 2: This is what the splash screen looks like when I use the "progress bar with a message".
Image SplashScreenWithProgressBar

If I were to comment out that line of code and replace it with the line beneath it (i.e., screen.setProgress(i), the progress bar will look like this:

Figure 3: This is what the splash screen looks like when I don't use the "progress bar with a message". Note how the progress bar differs from Figure 2.
Image SplashScreenProgressBarNoMessage


up previous next contents
Next: Closing/destroying the splash screen Up: How to create and Previous: Initializing the splash screen   Contents