public abstract class Preloader extends Application
A preloader is a small application that is started before the main application to customize the startup experience. The preloader:
The default preloader is shown on top of the application Stage, which is not visible until the preloader is visible. The preloader need to hide itself to make the application visible. Good practice is to do this no earlier than right before application.start() is called, as otherwise application itself is not visible.
The preloader may also cooperate with the application to achieve advanced visual effects or share data (e.g. to implement login screen). The preloader gets a reference to the application and may pull data it needs for cooperation from the application if the application implements an interface that the preloader knows about and relies upon. Generally it is not recommended to design preloaders in such a way that an application would call them directly, as this will result in bad user experience if the application is signed and the preloader is not.
If the application does not specify a preloader, then the default preloader is used. Default preloader appearance can be customized (set of parameters is TBD).
Custom preloader implementations should follow these rules:
Applications may also send custom notification to the preloader using the
notifyPreloader
method. This way a preloader may
also show application initialization progress.
Note that preloaders are subject to the same rules as other JavaFX applications including FX threading rules. In particular, the class constructor and init() method will be called on a non-FX thread and start() will be executed on the FX application thread. This also means that the application constructor/init() will run concurrently with preloader start().
Callbacks on preloader notification will be delivered on the FX application thread.
Shutdown (including when stop() is called) is TBD.
Modifier and Type | Class and Description |
---|---|
static class |
Preloader.ErrorNotification
Preloader notification that reports an error.
|
static interface |
Preloader.PreloaderNotification
Marker interface for all Preloader notification.
|
static class |
Preloader.ProgressNotification
Preloader notification that reports progress.
|
static class |
Preloader.StateChangeNotification
A notification that signals a change in the application state.
|
Application.Parameters
STYLESHEET_CASPIAN, STYLESHEET_MODENA
Constructor and Description |
---|
Preloader() |
Modifier and Type | Method and Description |
---|---|
void |
handleApplicationNotification(Preloader.PreloaderNotification info)
Indicates an application-generated notification.
|
boolean |
handleErrorNotification(Preloader.ErrorNotification info)
Called when an error occurs.
|
void |
handleProgressNotification(Preloader.ProgressNotification info)
Indicates download progress.
|
void |
handleStateChangeNotification(Preloader.StateChangeNotification info)
Indicates a change in application state.
|
getHostServices, getParameters, getUserAgentStylesheet, init, launch, launch, notifyPreloader, setUserAgentStylesheet, start, stop
public void handleProgressNotification(Preloader.ProgressNotification info)
notifyPreloader
.
The implementation of this method provided by the Preloader class does nothing.
info
- the progress notificationpublic void handleStateChangeNotification(Preloader.StateChangeNotification info)
The implementation of this method provided by the Preloader class does nothing.
info
- the state change notificationpublic void handleApplicationNotification(Preloader.PreloaderNotification info)
notifyPreloader
.
Applications should not call this method directly, but should use
notifyPreloader
instead to avoid mixed code dialog issues.
The implementation of this method provided by the Preloader class does nothing.
info
- the application-generated notificationpublic boolean handleErrorNotification(Preloader.ErrorNotification info)
The implementation of this method provided by the Preloader class returns false, indicating that the default error handler should show the message to the user.
info
- the error notification describing the cause of this errorSubmit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2008, 2017, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.