- MOZILLA, FIREFOX, SEAMONKEY























|
|
Java Application Template GUI Tutorial Part 1/5 - How to make an executable JAR file
This tutorial presents an Java application template to get you started with your own java program.
For a simpler version take a look at:
How to make a JAVA application - executable JAR archive
Screenshot of the GUI of the Java Application:
In order to create a professional looking application, we need a splash screen. This feature displays a
splash image while the application is loading, so the user will know that it is actually loading and
not hanging or crashing.
The class Splash.java loads the image from the JAR archive, hands it over to the SplashWindow-class
and invokes the Main-class, which contains the actual program.
Splash.java:
// JAVA Application Template (C) 2005 www.captain.at
// class Splash: displays the splash screen and invokes the main-class in Main.java
import java.awt.Frame;
import java.awt.Toolkit;
import java.net.URL;
import java.io.*;
public class Splash {
public static void main(String[] args) {
Frame splashFrame = null;
URL imageURL = Splash.class.getResource("splash.gif");
if (imageURL != null) {
splashFrame = SplashWindow.splash(
Toolkit.getDefaultToolkit().createImage(imageURL) );
} else {
System.err.println("Splash image not found");
}
try {
Class.forName("Main").getMethod("main", new Class[]
{String[].class}).invoke(null, new Object[] {args});
} catch (Throwable e) {
e.printStackTrace();
System.err.flush();
System.exit(10);
}
if (splashFrame != null) splashFrame.dispose();
}
}
PART 1
PART 2
PART 3
PART 4
PART 5
Last-Modified: Sat, 04 Feb 2006 16:03:11 GMT
|
|