If your application is packaged in a jar file, you can use the
"SplashScreen-Image" option in a manifest file to show a splash screen.
Place the image in the jar archive and specify the path in the option.
The path should not have a leading slash.
For example, in the manifest.mf file:
Manifest-Version: 1.0 Main-Class: Test SplashScreen-Image: filename.gif
If the Java implementation provides the command-line interface and you run
your application by using the command line or a shortcut, use the Java
application launcher option to show a splash screen. The Oracle reference
implementation allows you to specify the splash screen image location with
the -splash: option.
For example:
java -splash:filename.gif TestHiDPI scaled image is also supported. Unscaled image name i.e. filename.gif should be passed in
manifest.mf/-splash: option for all image types irrespective of
HiDPI and Non-HiDPI.
Following is the naming convention for scaled images.
Screen scale 1.25: [email protected]
Screen scale 1.50: [email protected]
Screen scale 2: [email protected] and [email protected] both are supported
Screen scale 2.50: [email protected]
Screen scale 3: [email protected] and [email protected] both are supported
The command line interface has higher precedence over the manifest
setting.
The splash screen will be displayed as faithfully as possible to present the whole splash screen image given the limitations of the target platform and display.
It is implied that the specified image is presented on the screen "as is", i.e. preserving the exact color values as specified in the image file. Under certain circumstances, though, the presented image may differ, e.g. when applying color dithering to present a 32 bits per pixel (bpp) image on a 16 or 8 bpp screen. The native platform display configuration may also affect the colors of the displayed image (e.g. color profiles, etc.)
The SplashScreen class provides the API for controlling the splash
screen. This class may be used to close the splash screen, change the splash
screen image, get the splash screen native window position/size, and paint
in the splash screen. It cannot be used to create the splash screen. You
should use the options provided by the Java implementation for that.
This class cannot be instantiated. Only a single instance of this class
can exist, and it may be obtained by using the getSplashScreen()
static method. In case the splash screen has not been created at
application startup via the command line or manifest file option,
the getSplashScreen method returns null.
| Modifier and Type | Field and Description |
|---|---|
| private BufferedImage | |
| private URL | |
| private static final PlatformLogger | |
| private final long | |
| private static SplashScreen | theInstance
The instance reference for the singleton. |
| private static boolean |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| private static native void | |
| private static native Rectangle | |
| private static native String | |
| private static native String | |
| private static native long | |
| private static native float | |
| private static native boolean | |
| private static native boolean | |
| private static native void | |
| private void | |
| public void | |
| public Graphics2D | Returns: graphics context for the splash screen overlay surfaceCreates a graphics context (as a |
| public Rectangle | |
| public URL | Returns: URL for the current splash screen image fileReturns the current splash screen image. |
| public Dimension | |
| public static SplashScreen | getSplashScreen()
Returns the |
| public boolean | Returns: true if the splash screen is visible (has not been closed yet), false otherwiseDetermines whether the splash screen is visible. |
| pack-priv static void | |
| public void | setImageURL(URL
the non- imageURL)null URL for the new
splash screen imageChanges the splash screen image. |
| public void |
| image | back to summary |
|---|---|
| private BufferedImage image | |
| imageURL | back to summary |
|---|---|
| private URL imageURL | |
| log | back to summary |
|---|---|
| private static final PlatformLogger log | |
| splashPtr | back to summary |
|---|---|
| private final long splashPtr | |
| theInstance | back to summary |
|---|---|
| private static SplashScreen theInstance The instance reference for the singleton.
(
| |
| wasClosed | back to summary |
|---|---|
| private static boolean wasClosed | |
| SplashScreen | back to summary |
|---|---|
| pack-priv SplashScreen(long ptr) | |
| _close | back to summary |
|---|---|
| private static native void _close(long splashPtr) | |
| _getBounds | back to summary |
|---|---|
| private static native Rectangle _getBounds(long splashPtr) | |
| _getImageFileName | back to summary |
|---|---|
| private static native String _getImageFileName(long splashPtr) | |
| _getImageJarName | back to summary |
|---|---|
| private static native String _getImageJarName(long SplashPtr) | |
| _getInstance | back to summary |
|---|---|
| private static native long _getInstance() | |
| _getScaleFactor | back to summary |
|---|---|
| private static native float _getScaleFactor(long SplashPtr) | |
| _isVisible | back to summary |
|---|---|
| private static native boolean _isVisible(long splashPtr) | |
| _setImageData | back to summary |
|---|---|
| private static native boolean _setImageData(long SplashPtr, byte[] data) | |
| _update | back to summary |
|---|---|
| private static native void _update(long splashPtr, int[] data, int x, int y, int width, int height, int scanlineStride) | |
| checkVisible | back to summary |
|---|---|
| private void checkVisible() | |
| close | back to summary |
|---|---|
| public void close() throws IllegalStateException Hides the splash screen, closes the window, and releases all associated resources.
| |
| createGraphics | back to summary |
|---|---|
| public Graphics2D createGraphics() throws IllegalStateException Creates a graphics context (as a
The pixel (0, 0) in the coordinate space of the graphics context
corresponds to the origin of the splash screen native window bounds (see
| |
| getBounds | back to summary |
|---|---|
| public Rectangle getBounds() throws IllegalStateException Returns the bounds of the splash screen window as a You cannot control the size or position of the splash screen. The splash screen size is adjusted automatically when the image changes. The image may contain transparent areas, and thus the reported bounds may be larger than the visible splash screen image on the screen.
| |
| getImageURL | back to summary |
|---|---|
| public URL getImageURL() throws IllegalStateException Returns the current splash screen image.
| |
| getSize | back to summary |
|---|---|
| public Dimension getSize() throws IllegalStateException Returns the size of the splash screen window as a You cannot control the size or position of the splash screen. The splash screen size is adjusted automatically when the image changes. The image may contain transparent areas, and thus the reported size may be larger than the visible splash screen image on the screen.
| |
| getSplashScreen | back to summary |
|---|---|
| public static SplashScreen getSplashScreen() Returns the
| |
| isVisible | back to summary |
|---|---|
| public boolean isVisible() Determines whether the splash screen is visible. The splash screen may
be hidden using
Note that the native platform may delay presenting the splash screen
native window on the screen. The return value of
| |
| markClosed | back to summary |
|---|---|
| pack-priv static void markClosed() | |
| setImageURL | back to summary |
|---|---|
| public void setImageURL(URL imageURL) throws NullPointerException, IOException, IllegalStateException Changes the splash screen image. The new image is loaded from the specified URL; GIF, JPEG and PNG image formats are supported. The method returns after the image has finished loading and the window has been updated. The splash screen window is resized according to the size of the image and is centered on the screen.
| |
| update | back to summary |
|---|---|
| public void update() throws IllegalStateException Updates the splash window with current contents of the overlay image.
| |