FileDocCategorySizeDatePackage
Splash.javaAPI DocExample2448Wed Jan 27 11:34:16 GMT 1999None

Splash

public class Splash extends JFrame
Generalized Splash Screen, for applications (not Applets) The application that creates me should start a thread that sleeps a while, then calls my done() method.

Fields Summary
protected String
imName
The name of the Image
protected Image
im
The Image used to paint the screen
MediaTracker
mt
MediaTracker to load the image for us.
Constructors Summary
Splash(JFrame parent, String imgName)
Construct a Splash screen with the given image

		super("TestEdit initializing");
		im = Toolkit.getDefaultToolkit().getImage(imgName);
		mt = new MediaTracker(this);
		mt.addImage(im, 0);
		try {
			mt.waitForID(0);
		} catch(InterruptedException e) {
			System.err.println("Wonkey! INTR in waitForID!");
			return;
		}
		if (mt.isErrorID(0)) {
			System.err.println("Couldn't load Splash Image " +
				imgName);
			return;
		}
		getContentPane().add(new SplImage(im));
		//add(new SplImage(im));
		pack();

		addMouseListener(new MouseAdapter() {
			/** Let the user kill the Splash Screen anytime they want. */
			public void mouseClicked(MouseEvent e) {
				done();
			}
		});
	
Methods Summary
public voiddone()
Shut down this window. Called from this class' mouseClicked(), but also from the main application.

		setVisible(false);
		dispose();
	
public static voidmain(java.lang.String[] a)
The obligatory tiny test program. Normal use requires a thread in an AWT application; see JabaDex for example.

		//(new Splash("Testing...", "JabaSpl.gif")).setVisible(true);
		JFrame frm = new JFrame("Testing");
		frm.setVisible(true);
		(new Splash(frm, "JabaSpl.gif")).setVisible(true);