up previous next contents
Next: Updating the progress bar Up: How to create and Previous: Getting started   Contents

Initializing the splash screen

Initializing the splash screen is simple to do. The initialization is done in the SplashScreenMain class, and consists of the calls I mentioned earlier. The initialization method is shown in the listing that follows.

  private void splashScreenInit() {
    ImageIcon myImage = new ImageIcon(com.devdaily.splashscreen.SplashScreenMain.class.getResource("SplashImage.gif"));
    screen = new SplashScreen(myImage);
    screen.setLocationRelativeTo(null);
    screen.setProgressMax(100);
    screen.setScreenVisible(true);
  }

As you can see from this listing, the first thing you need to do is create an image. Next, the image is passed into the constructor of the SplashScreen. Positioning of the splash screen is handled by the setLocationRelativeTo call. The maximum value of the splash screen progress bar is handled in the setProgressMax call. This method simply calls the setMaximum method of the progress bar. Finally, the screen is made visible to the user with the setScreenVisible method.

This is all we have to do to initialize the splash screen. At this point it should be visible to the user. The next thing we want to do is start updating the progress bar as we initialize things in our application.


up previous next contents
Next: Updating the progress bar Up: How to create and Previous: Getting started   Contents