Class SplashScreen
The screen is a small, transparent window with the application's logo and a scanner bar below it: a light that sweeps from left to right and back, like the one of the reference design. The window has rounded corners and a thin frame; background, frame colour, corner radius, logo and an optional jingle are configurable, everything else follows the standard design of the framework.
An application activates it in BaseApp:
@Override
protected boolean isSplashScreenEnabled() {
return true;
}
@Override
protected SplashScreen createSplashScreen() {
return new SplashScreen()
.setLogo(getClass().getResource("icons/app-256.png"))
.setJingle(getClass().getResource("sounds/start.wav"));
}
The framework shows the screen at the beginning of the start-up and hides it as soon as the
main window is up. Without the activation (isSplashScreenEnabled() is false by
default) no splash screen is shown at all.
The jingle is played with the Java Sound API, so it has to be a sound file the JDK can play (WAV, AU or AIFF) - the application does not need the JavaFX media module for it.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ColorBackground of the splash window (standard design).static final doubleRadius of the rounded corners of the splash window (standard design).static final ColorColour of the frame around the splash window (standard design).static final ColorColour of the scanner light at its end (standard design).static final ColorColour of the scanner light at its start (standard design).static final ColorColour of the scanner track (standard design).static final doubleEdge length of the logo.static final DurationDuration of one sweep of the scanner light.static final doubleHeight of the scanner bar.static final doubleWidth of the scanning light.static final doubleWidth of the scanner bar. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a splash screen with the standard design and the framework's logo. -
Method Summary
Modifier and TypeMethodDescriptionThe minimum time the splash screen stays up, ornullif it goes away with the main window.voidhide()Hides the splash screen: the window fades out and closes.booleanWhether the splash screen is currently shown.The time the splash screen still has to stay up.setBackgroundColor(Color background) Sets the background colour of the splash window.setCornerRadius(double cornerRadius) Sets the radius of the rounded corners of the splash window.setDuration(Duration duration) Sets the minimum time the splash screen stays up.setFrameColor(Color frameColor) Sets the colour of the frame around the splash window.Sets the jingle that is played when the splash screen appears.Sets the logo of the application from a resource.Sets the logo of the application.voidshow()Shows the splash screen.
-
Field Details
-
DEFAULT_BACKGROUND
Background of the splash window (standard design). -
DEFAULT_FRAME_COLOR
Colour of the frame around the splash window (standard design). -
DEFAULT_CORNER_RADIUS
public static final double DEFAULT_CORNER_RADIUSRadius of the rounded corners of the splash window (standard design).- See Also:
-
DEFAULT_SCANNER_TRACK
Colour of the scanner track (standard design). -
DEFAULT_SCANNER_START
Colour of the scanner light at its start (standard design). -
DEFAULT_SCANNER_END
Colour of the scanner light at its end (standard design). -
LOGO_SIZE
public static final double LOGO_SIZEEdge length of the logo.- See Also:
-
SCANNER_WIDTH
public static final double SCANNER_WIDTHWidth of the scanner bar.- See Also:
-
SCANNER_HEIGHT
public static final double SCANNER_HEIGHTHeight of the scanner bar.- See Also:
-
SCANNER_LIGHT_WIDTH
public static final double SCANNER_LIGHT_WIDTHWidth of the scanning light.- See Also:
-
SCAN_DURATION
Duration of one sweep of the scanner light.
-
-
Constructor Details
-
SplashScreen
public SplashScreen()Creates a splash screen with the standard design and the framework's logo.
-
-
Method Details
-
setLogo
Sets the logo of the application.- Parameters:
logo- the logo, ornullfor no logo- Returns:
- this splash screen
-
setLogo
Sets the logo of the application from a resource.- Parameters:
logo- the resource of the logo, ornullfor no logo- Returns:
- this splash screen
-
setBackgroundColor
Sets the background colour of the splash window.- Parameters:
background- the colour- Returns:
- this splash screen
-
setFrameColor
Sets the colour of the frame around the splash window.- Parameters:
frameColor- the colour- Returns:
- this splash screen
-
setCornerRadius
Sets the radius of the rounded corners of the splash window.- Parameters:
cornerRadius- the radius in pixels- Returns:
- this splash screen
-
setJingle
Sets the jingle that is played when the splash screen appears.Setting the jingle while the splash screen is already up plays it right away - the framework does it that way, because the application decides with its configuration whether there is a jingle at all, and the configuration is read while the splash screen is running.
- Parameters:
jingle- the resource of the sound file, ornullfor no jingle- Returns:
- this splash screen
-
setDuration
Sets the minimum time the splash screen stays up.Without a duration the splash screen goes away as soon as the main window is up. With a duration it stays at least that long - a short start-up would otherwise flash the splash screen up for a fraction of a second only.
- Parameters:
duration- the minimum display time, ornullfor none- Returns:
- this splash screen
-
getDuration
The minimum time the splash screen stays up, ornullif it goes away with the main window.- Returns:
- the minimum display time or
null
-
remainingDuration
The time the splash screen still has to stay up.- Returns:
- the remaining time, zero if there is no duration or it is over
-
show
public void show()Shows the splash screen.The window appears centred on the screen, the scanner starts and the jingle is played. Calling the method again while the splash screen is up does nothing.
-
hide
public void hide()Hides the splash screen: the window fades out and closes.The window is closed in any case - the fade is a nice touch, but it only runs while the JavaFX thread is free. A splash screen that stays open would keep the application alive, so a second timer closes the window in any case.
-
isShowing
public boolean isShowing()Whether the splash screen is currently shown.- Returns:
- true if splash screen is visible
-