Splashpublic 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 | imNameThe name of the Image | protected Image | imThe Image used to paint the screen | MediaTracker | mtMediaTracker 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 void | done()Shut down this window. Called from this class' mouseClicked(),
but also from the main application.
setVisible(false);
dispose();
| public static void | main(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);
|
|