Reputation: 56912
I see some Swing apps (like Eclipse) that load with a Welcome!/"splash" page. What kind of Swing component is this? Its sort of like a web page (like the old <imagemap>
s!) embedded inside a Swing app and is very cool.
Upvotes: 2
Views: 531
Reputation: 10136
You could design the splash screen using an image editor, like Photoshop or GIMP. Save the image in a format that Java supports, like JPG, GIF, or PNG. Design the splash screen at a resolution that will work on low resolution devices like netbooks and projectors.
E.g. the Eclipse splash screen is ~450x300 pixels:
To display the image, you could use a JDialog whose border and close button have been hidden via setUndecorated(true)
. The JDialog could contain a single JLabel. Size both the JDialog and JLabel to be able to display the entire image. The JLabel's icon
property should be set to the splash screen image.
You could display the splash screen for a fixed amount of time by employing Swing's Timer class. Consider allowing the user to optionally disable the splash screen so they don't always have to waste time watching it every time they start your program.
Or, rather than using a timer to display the splash screen for a fixed amount of time, you could consider hiding the splash screen as soon as the application has finished initializing. What "initializing the application" entails is specific to your application. This is the approach that Eclipse uses (its splash screen even has a progress bar).
Your question actually appears to be about the Eclipse "Welcome screen" (see screenshot below), not the Eclipse "splash screen". The Welcome Screen does include clickable areas. Java has some limited abilities to display HTML content. See http://docs.oracle.com/javase/tutorial/uiswing/components/html.html for some details. Java's built in support for HTML is pretty limited, and so it may not meet your needs. Here is a guide that talks about using a read-only JEditorPane to display HTML content, and capturing hyperlink click events to perform custom actions: http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-JEditorPane.html
Upvotes: 4
Reputation: 12883
Its really easy to do. Just create a splash screen entry in your manifest file that points to an image resource in your jar file.
e.g.
SplashScreen-Image: resources/splash.png
The image can even have transparency, so you can make it appear to be non-rectangular.
Upvotes: 2
Reputation: 1480
Checkout this tutorial http://docs.oracle.com/javase/tutorial/uiswing/misc/splashscreen.html
Upvotes: 3