APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javafx.application

public abstract Class Preloader

extends Application
Class Inheritance

Class that is extended to define an optional preloader for a JavaFX Application. An application may contain a preloader that is used to improve the application loading experience.

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:

  1. a custom preloader class should extend Preloader
  2. classes needed for preloader need to be packaged in the separate jar.

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.

Since
JavaFX 2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Preloader.ErrorNotification

Preloader notification that reports an error.

public static interface
Preloader.PreloaderNotification

Marker interface for all Preloader notification.

public static class
Preloader.ProgressNotification

Preloader notification that reports progress.

public static class
Preloader.StateChangeNotification

A notification that signals a change in the application state.

Field Summary

Modifier and TypeField and Description
private static final String
Inherited from javafx.application.Application:
STYLESHEET_CASPIANSTYLESHEET_MODENA

Constructor Summary

AccessConstructor and Description
public
Preloader()

Constructor for subclasses to call.

Method Summary

Modifier and TypeMethod and Description
public void
handleApplicationNotification(Preloader.PreloaderNotification
the application-generated notification
info
)

Indicates 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.
handleErrorNotification
(Preloader.ErrorNotification
the error notification describing the cause of this error
info
)

Called when an error occurs.

public void
handleProgressNotification(Preloader.ProgressNotification
the progress notification
info
)

Indicates download progress.

public void
handleStateChangeNotification(Preloader.StateChangeNotification
the state change notification
info
)

Indicates a change in application state.

Inherited from javafx.application.Application:
getHostServicesgetParametersgetUserAgentStylesheetinitlaunchlaunchnotifyPreloadersetUserAgentStylesheetstartstop

Field Detail

lineSeparatorback to summary
private static final String lineSeparator

Constructor Detail

Preloaderback to summary
public Preloader()

Constructor for subclasses to call.

Method Detail

handleApplicationNotificationback to summary
public void handleApplicationNotification(Preloader.PreloaderNotification info)

Indicates an application-generated notification. This method is called by the FX runtime to deliver a notification sent via 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.

Parameters
info:Preloader.PreloaderNotification

the application-generated notification

handleErrorNotificationback to summary
public boolean handleErrorNotification(Preloader.ErrorNotification info)

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.

Parameters
info:Preloader.ErrorNotification

the error notification describing the cause of this error

Returns:boolean

true if error was shown to the user by preloader and no additional visualization is needed; otherwise, false.

handleProgressNotificationback to summary
public void handleProgressNotification(Preloader.ProgressNotification info)

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 notifyPreloader.

The implementation of this method provided by the Preloader class does nothing.

Parameters
info:Preloader.ProgressNotification

the progress notification

handleStateChangeNotificationback to summary
public void handleStateChangeNotification(Preloader.StateChangeNotification info)

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.

Parameters
info:Preloader.StateChangeNotification

the state change notification

javafx.application back to summary

public Class Preloader.ErrorNotification

extends Object
implements PreloaderNotification
Class Inheritance
All Implemented Interfaces
javafx.application.Preloader.PreloaderNotification

Preloader notification that reports an error. This is delivered to preloader in case of problem with application startup.
Since
JavaFX 2.0

Field Summary

Modifier and TypeField and Description
private Throwable
private String
private String

Constructor Summary

AccessConstructor 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.

Method Summary

Modifier and TypeMethod and Description
public Throwable

Returns:

the cause of the error, or null
getCause
()

Retrieves the Exception or Error associated with this error notification, if any.

public String

Returns:

the description of the error
getDetails
()

Retrieves the description of the error.

public String

Returns:

the location, or null
getLocation
()

Retrieves the URL associated with this error, if any.

public String

Returns:

a string representation of this ErrorNotification object.
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of this ErrorNotification object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

causeback to summary
private Throwable cause
detailsback to summary
private String details
locationback to summary
private String location

Constructor Detail

ErrorNotificationback to summary
public ErrorNotification(String location, String details, Throwable cause)

Constructs an error notification.

Parameters
location:String

the URL associated with an error (if any); may be null

details:String

a string describing the error; must be non-null

cause:Throwable

the cause of the error; may be null

Method Detail

getCauseback to summary
public Throwable getCause()

Retrieves the Exception or Error associated with this error notification, if any. It may be null.

Returns:Throwable

the cause of the error, or null

getDetailsback to summary
public String getDetails()

Retrieves the description of the error. It may be the empty string, but is always non-null.

Returns:String

the description of the error

getLocationback 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.

Returns:String

the location, or null

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string representation of this ErrorNotification object.

Returns:String

a string representation of this ErrorNotification object.

Annotations
@Override
javafx.application back to summary

public Interface Preloader.PreloaderNotification

Known Direct Implementers
javafx.application.Preloader.ErrorNotification, javafx.application.Preloader.ProgressNotification, javafx.application.Preloader.StateChangeNotification

Marker interface for all Preloader notification.
Since
JavaFX 2.0
javafx.application back to summary

public Class Preloader.ProgressNotification

extends Object
implements PreloaderNotification
Class Inheritance
All Implemented Interfaces
javafx.application.Preloader.PreloaderNotification

Preloader notification that reports progress. This is typically used to report progress while downloading and initializing the application.
Since
JavaFX 2.0

Field Summary

Modifier and TypeField and Description
private final String
private final double

Constructor Summary

AccessConstructor 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.

Method Summary

Modifier and TypeMethod and Description
private String

Returns:

the details of this notification
getDetails
()

Retrieves the details of the progress notification

public double

Returns:

the progress
getProgress
()

Retrieves the progress for this notification.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

detailsback to summary
private final String details
progressback to summary
private final double progress

Constructor Detail

ProgressNotificationback to summary
public ProgressNotification(double progress)

Constructs a progress notification.

Parameters
progress: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.

ProgressNotificationback to summary
private ProgressNotification(double progress, String details)

Constructs a progress notification.

Parameters
progress: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.

details:String

the details of this notification

Method Detail

getDetailsback to summary
private String getDetails()

Retrieves the details of the progress notification

Returns:String

the details of this notification

getProgressback 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.

Returns:double

the progress

javafx.application back to summary

public Class Preloader.StateChangeNotification

extends Object
implements PreloaderNotification
Class Inheritance
All Implemented Interfaces
javafx.application.Preloader.PreloaderNotification

A notification that signals a change in the application state. A state change notification is sent to a preloader immediately prior to loading the application class (and constructing an instance), calling the application init method, or calling the application start method.
Since
JavaFX 2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
Preloader.StateChangeNotification.Type

Enum that defines the type of change associated with this notification

Field Summary

Modifier and TypeField and Description
private final Application
private final Preloader.StateChangeNotification.Type

Constructor Summary

AccessConstructor and Description
public
StateChangeNotification(Preloader.StateChangeNotification.Type
the type of this notification.
notificationType
)

Constructs a StateChangeNotification of the specified type.

public
StateChangeNotification(Preloader.StateChangeNotification.Type
the type of this notification.
notificationType
,
Application
the application instance associated with this notification.
application
)

Constructs an StateChangeNotification of the specified type for the specified application.

Method Summary

Modifier and TypeMethod and Description
public Application

Returns:

the Application instance or null.
getApplication
()

Returns the Application instance associated with this notification.

public Preloader.StateChangeNotification.Type

Returns:

one of: BEFORE_LOAD, BEFORE_INIT, BEFORE_START
getType
()

Returns the type of notification.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

applicationback to summary
private final Application application
notificationTypeback to summary
private final Preloader.StateChangeNotification.Type notificationType

Constructor Detail

StateChangeNotificationback to summary
public StateChangeNotification(Preloader.StateChangeNotification.Type notificationType)

Constructs a StateChangeNotification of the specified type.

Parameters
notificationType:Preloader.StateChangeNotification.Type

the type of this notification.

StateChangeNotificationback to summary
public StateChangeNotification(Preloader.StateChangeNotification.Type notificationType, Application application)

Constructs an StateChangeNotification of the specified type for the specified application.

Parameters
notificationType:Preloader.StateChangeNotification.Type

the type of this notification.

application:Application

the application instance associated with this notification.

Method Detail

getApplicationback 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.

Returns:Application

the Application instance or null.

getTypeback to summary
public Preloader.StateChangeNotification.Type getType()

Returns the type of notification.

Returns:Preloader.StateChangeNotification.Type

one of: BEFORE_LOAD, BEFORE_INIT, BEFORE_START

javafx.application back to summary

public final Enum Preloader.StateChangeNotification.Type

extends Enum<Preloader.StateChangeNotification.Type>
Class Inheritance

Enum that defines the type of change associated with this notification
Since
JavaFX 2.0

Field Summary

Modifier and TypeField and Description
public static final Preloader.StateChangeNotification.Type
BEFORE_INIT

Indicates that the application's init method is about to be called.

public static final Preloader.StateChangeNotification.Type
BEFORE_LOAD

Indicates that the application class is about to be loaded and constructed.

public static final Preloader.StateChangeNotification.Type
BEFORE_START

Indicates that the application's start method is about to be called.

Constructor Summary

AccessConstructor and Description
private
Type()

Field Detail

BEFORE_INITback to summary
public static final Preloader.StateChangeNotification.Type BEFORE_INIT

Indicates that the application's init method is about to be called.

BEFORE_LOADback to summary
public static final Preloader.StateChangeNotification.Type BEFORE_LOAD

Indicates that the application class is about to be loaded and constructed.

BEFORE_STARTback to summary
public static final Preloader.StateChangeNotification.Type BEFORE_START

Indicates that the application's start method is about to be called.

Constructor Detail

Typeback to summary
private Type()

Method Detail

valueOfback to summary
public static Preloader.StateChangeNotification.Type valueOf(String name)
valuesback to summary
public static Preloader.StateChangeNotification.Type[] values()