The full "driver" classThat finishes my discussion of the "driver" class that I used to build and test my SplashScreen class. For completeness, here is a listing of the full source code of this class.
package com.devdaily.splashscreen;
import javax.swing.UIManager;
import javax.swing.ImageIcon;
public class SplashScreenMain {
SplashScreen screen;
public SplashScreenMain() {
// initialize the splash screen
splashScreenInit();
// do something here to simulate the program doing something that
// is time consuming
for (int i = 0; i <= 100; i++)
{
for (long j=0; j<50000; ++j)
{
String poop = " " + (j + i);
}
// run either of these two -- not both
screen.setProgress("Yo " + i, i); // progress bar with a message
//screen.setProgress(i); // progress bar with no message
}
splashScreenDestruct();
System.exit(0);
}
private void splashScreenDestruct() {
screen.setScreenVisible(false);
}
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);
}
public static void main(String[] args)
{
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception e) {
e.printStackTrace();
}
new SplashScreenMain();
}
}
You can also download the SplashScreenMain.java class.
Next: The SplashScreen implementation Up: How to create and Previous: Closing/destroying the splash screen Contents |