Captain's Universe Home
Captain's Universe Home
Cosmic Ray Muon DetectorTeleGarden Pages
Time on MarsBryophyllum Plants
Jupiter Radio AstronomyAncient Pages
Salzburg Tourist GuideEarth Magnetometer
  H O M E     AJAX & MORE     LINUX & MORE     RTAI     XENOMAI     ADEOS IPIPE      
    JAVA & BROWSERS     *NIX     ELECTRONICS     REVIEWS     ARTEMIA     FAIRY SHRIMP      



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:
Java Application Template Screenshot

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

Google
 
Web www.captain.at
go to top
© 1996-2010 . All rights reserved.
No reproduction, distribution, publishing or transmission of the copyrighted materials at this site is permitted. Policy
go to top