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 |
|---|---|
| public static class | Preloader.
Preloader notification that reports an error. |
| public static interface | Preloader.
Marker interface for all Preloader notification. |
| public static class | Preloader.
Preloader notification that reports progress. |
| public static class | Preloader.
A notification that signals a change in the application state. |
| Modifier and Type | Field and Description |
|---|---|
| private static final String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | handleApplicationNotification(Preloader.
the application-generated notification infoIndicates an application-generated notification. |
| public boolean | Returns: true if error was shown to the user by preloader and no additional visualization is needed; otherwise, false.the error notification describing the cause of this error infoCalled when an error occurs. |
| public void | handleProgressNotification(Preloader.
the progress notification infoIndicates download progress. |
| public void | handleStateChangeNotification(Preloader.
the state change notification infoIndicates a change in application state. |
| lineSeparator | back to summary |
|---|---|
| private static final String lineSeparator | |
| Preloader | back to summary |
|---|---|
| public Preloader() Constructor for subclasses to call. | |
| handleApplicationNotification | back to summary |
|---|---|
| public void handleApplicationNotification(Preloader. Indicates an application-generated notification.
This method is called by the FX runtime to deliver a notification sent
via
Applications should not call this method directly, but should use
The implementation of this method provided by the Preloader class does nothing.
| |
| handleErrorNotification | back to summary |
|---|---|
| public boolean handleErrorNotification(Preloader. Called when an error occurs. 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.
| |
| handleProgressNotification | back to summary |
|---|---|
| public void handleProgressNotification(Preloader. Indicates download progress.
This method is called by the FX runtime to indicate progress while
application resources are being loaded. It will not be called to deliver
a ProgressNotification sent to The implementation of this method provided by the Preloader class does nothing.
| |
| handleStateChangeNotification | back to summary |
|---|---|
| public void handleStateChangeNotification(Preloader. Indicates a change in application state. This method is called by the FX runtime as part of the application life-cycle. The implementation of this method provided by the Preloader class does nothing.
| |
| Modifier and Type | Field and Description |
|---|---|
| private Throwable | |
| private String | |
| private String |
| Access | Constructor and Description |
|---|---|
| public | ErrorNotification(String
the URL associated with an error (if any); may be null location, String a string describing the error; must be non-null details, Throwable the cause of the error; may be null cause)Constructs an error notification. |
| Modifier and Type | Method and Description |
|---|---|
| public Throwable | Returns: the cause of the error, or nullRetrieves the Exception or Error associated with this error notification, if any. |
| public String | |
| public String | |
| public String | Returns: a string representation of thisErrorNotification object.Overrides java. Returns a string representation of this |
| cause | back to summary |
|---|---|
| private Throwable cause | |
| details | back to summary |
|---|---|
| private String details | |
| location | back to summary |
|---|---|
| private String location | |
| ErrorNotification | back to summary |
|---|---|
| public ErrorNotification(String location, String details, Throwable cause) Constructs an error notification. | |
| getCause | back to summary |
|---|---|
| public Throwable getCause() Retrieves the Exception or Error associated with this error notification, if any. It may be null.
| |
| getDetails | back to summary |
|---|---|
| public String getDetails() Retrieves the description of the error. It may be the empty string, but is always non-null.
| |
| getLocation | back to summary |
|---|---|
| public String getLocation() Retrieves the URL associated with this error, if any. For example, if there is a download or singing check error, this will be the URL of the jar file that has the problem. It may be null.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string representation of this | |
| Modifier and Type | Field and Description |
|---|---|
| private final String | |
| private final double |
| Access | Constructor and Description |
|---|---|
| public | ProgressNotification(double
a value indicating the progress.
A negative value for progress indicates that the progress is
indeterminate. A value between 0 and 1 indicates the amount
of progress. Any value greater than 1 is interpreted as 1. progress)Constructs a progress notification. |
| private | ProgressNotification(double
a value indicating the progress.
A negative value for progress indicates that the progress is
indeterminate. A value between 0 and 1 indicates the amount
of progress. Any value greater than 1 is interpreted as 1. progress, String the details of this notification details)Constructs a progress notification. |
| Modifier and Type | Method and Description |
|---|---|
| private String | Returns: the details of this notificationRetrieves the details of the progress notification |
| public double |
| details | back to summary |
|---|---|
| private final String details | |
| progress | back to summary |
|---|---|
| private final double progress | |
| ProgressNotification | back to summary |
|---|---|
| public ProgressNotification(double progress) Constructs a progress notification.
| |
| ProgressNotification | back to summary |
|---|---|
| private ProgressNotification(double progress, String details) Constructs a progress notification.
| |
| getDetails | back to summary |
|---|---|
| private String getDetails() Retrieves the details of the progress notification
| |
| getProgress | back to summary |
|---|---|
| public double getProgress() Retrieves the progress for this notification. Progress is in the range of 0 to 1, or is negative for indeterminate progress.
| |
| Modifier and Type | Class and Description |
|---|---|
| public static enum | Preloader.
Enum that defines the type of change associated with this notification |
| Modifier and Type | Field and Description |
|---|---|
| private final Application | |
| private final Preloader. |
| Access | Constructor and Description |
|---|---|
| public | StateChangeNotification(Preloader.
the type of this notification. notificationTypeConstructs a StateChangeNotification of the specified type. |
| public | StateChangeNotification(Preloader.
the type of this notification. notificationType,the application instance associated with this
notification. application)Constructs an StateChangeNotification of the specified type for the specified application. |
| Modifier and Type | Method and Description |
|---|---|
| public Application | Returns: the Application instance or null.Returns the Application instance associated with this notification. |
| public Preloader. |
| application | back to summary |
|---|---|
| private final Application application | |
| notificationType | back to summary |
|---|---|
| private final Preloader. | |
| StateChangeNotification | back to summary |
|---|---|
| public StateChangeNotification(Preloader. Constructs a StateChangeNotification of the specified type.
| |
| StateChangeNotification | back to summary |
|---|---|
| public StateChangeNotification(Preloader. Constructs an StateChangeNotification of the specified type for the specified application.
| |
| getApplication | back to summary |
|---|---|
| public Application getApplication() Returns the Application instance associated with this notification. This is null for a BEFORE_LOAD notification and non-null for other notification types.
| |
| getType | back to summary |
|---|---|
| public Preloader. Returns the type of notification.
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final Preloader. | BEFORE_INIT
Indicates that the application's init method is about to be called. |
| public static final Preloader. | BEFORE_LOAD
Indicates that the application class is about to be loaded and constructed. |
| public static final Preloader. | BEFORE_START
Indicates that the application's start method is about to be called. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static Preloader. | |
| public static Preloader. |
| BEFORE_INIT | back to summary |
|---|---|
| public static final Preloader. Indicates that the application's init method is about to be called. | |
| BEFORE_LOAD | back to summary |
|---|---|
| public static final Preloader. Indicates that the application class is about to be loaded and constructed. | |
| BEFORE_START | back to summary |
|---|---|
| public static final Preloader. Indicates that the application's start method is about to be called. | |
| Type | back to summary |
|---|---|
| private Type() | |
| valueOf | back to summary |
|---|---|
| public static Preloader. | |
| values | back to summary |
|---|---|
| public static Preloader. | |