Class Platform
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic interfaceContains preferences of the current platform.
- 
Property SummaryPropertiesTypePropertyDescriptionstatic ReadOnlyBooleanPropertyIndicates whether or not accessibility is active.
- 
Method SummaryModifier and TypeMethodDescriptionstatic ReadOnlyBooleanPropertyIndicates whether or not accessibility is active.static booleanIndicates whether a nested event loop can be started from the current thread in the current state.static ObjectEnter a nested event loop and block until the corresponding exitNestedEventLoop call is made.static voidexit()Causes the JavaFX application to terminate.static voidexitNestedEventLoop(Object key, Object rval) Exit a nested event loop and unblock the caller of the corresponding enterNestedEventLoop.static Platform.PreferencesGets the preferences of the current platform.static booleanGets the value of theaccessibilityActiveproperty.static booleanReturns true if the calling thread is the JavaFX Application Thread.static booleanGets the value of the implicitExit attribute.isKeyLocked(KeyCode keyCode) Returns a flag indicating whether the key corresponding tokeyCodeis in the locked (or "on") state.static booleanChecks whether a nested event loop is running, returning true to indicate that one is, and false if there are no nested event loops currently running.static booleanisSupported(ConditionalFeature feature) Queries whether a specific conditional feature is supported by the platform.static voidRequests the Java Runtime to perform a pulse.static voidRun the specified Runnable on the JavaFX Application Thread at some unspecified time in the future.static voidsetImplicitExit(boolean implicitExit) Sets the implicitExit attribute to the specified value.static voidThis method starts the JavaFX runtime.
- 
Property Details- 
accessibilityActiveIndicates whether or not accessibility is active. This property is typically set to true the first time an assistive technology, such as a screen reader, requests information about any JavaFX window or its children.This method may be called from any thread. - Since:
- JavaFX 8u40
- See Also:
 
 
- 
- 
Method Details- 
startupThis method starts the JavaFX runtime. The specified Runnable will then be called on the JavaFX Application Thread. In general it is not necessary to explicitly call this method, since it is invoked as a consequence of how most JavaFX applications are built. However there are valid use cases for calling this method directly. Because this method starts the JavaFX runtime, there is not yet any JavaFX Application Thread, so it is normal that this method is called directly on the main thread of the application.This method may or may not return to the caller before the run method of the specified Runnable has been called. In any case, this method is not blocked on the specified Runnable being executed. Once this method returns, you may call runLater(Runnable)with additional Runnables. Those Runnables will be called, also on the JavaFX Application Thread, after the Runnable passed into this method has been called.As noted, it is normally the case that the JavaFX Application Thread is started automatically. It is important that this method only be called when the JavaFX runtime has not yet been initialized. Situations where the JavaFX runtime is started automatically include: - For standard JavaFX applications that extend Application, and use either the Java launcher or one of the launch methods in the Application class to launch the application, the FX runtime is initialized automatically by the launcher before theApplicationclass is loaded.
- For Swing applications that use JFXPanelto display FX content, the FX runtime is initialized when the firstJFXPanelinstance is constructed.
- For SWT application that use FXCanvasto display FX content, the FX runtime is initialized when the firstFXCanvasinstance is constructed.
 When an application does not follow any of these common approaches, then it becomes the responsibility of the developer to manually start the JavaFX runtime by calling this startup method. Calling this method when the JavaFX runtime is already running will result in an IllegalStateExceptionbeing thrown - it is only valid to request that the JavaFX runtime be started once.Note: The JavaFX classes must be loaded from a set of named javafx.*modules on the module path. Loading the JavaFX classes from the classpath is not supported. A warning is logged when the JavaFX runtime is started if the JavaFX classes are not loaded from the expected named module. This warning is logged regardless of whether the JavaFX runtime was started by calling this method or automatically as described above.- Parameters:
- runnable- the Runnable whose run method will be executed on the JavaFX Application Thread once it has been started
- Throws:
- IllegalStateException- if the JavaFX runtime is already running
- Since:
- 9
- See Also:
 
- For standard JavaFX applications that extend 
- 
runLaterRun the specified Runnable on the JavaFX Application Thread at some unspecified time in the future. This method, which may be called from any thread, will post the Runnable to an event queue and then return immediately to the caller. The Runnables are executed in the order they are posted. A runnable passed into the runLater method will be executed before any Runnable passed into a subsequent call to runLater. If this method is called after the JavaFX runtime has been shutdown, the call will be ignored: the Runnable will not be executed and no exception will be thrown.NOTE: applications should avoid flooding JavaFX with too many pending Runnables. Otherwise, the application may become unresponsive. Applications are encouraged to batch up multiple operations into fewer runLater calls. Additionally, long-running operations should be done on a background thread where possible, freeing up the JavaFX Application Thread for GUI operations. This method must not be called before the FX runtime has been initialized. For standard JavaFX applications that extend Application, and use either the Java launcher or one of the launch methods in the Application class to launch the application, the FX runtime is initialized by the launcher before the Application class is loaded. For Swing applications that use JFXPanel to display FX content, the FX runtime is initialized when the first JFXPanel instance is constructed. For SWT application that use FXCanvas to display FX content, the FX runtime is initialized when the first FXCanvas instance is constructed. For applications that do not follow any of these approaches, then it is necessary to manually start the JavaFX runtime by callingstartup(Runnable)once.Memory consistency effects: Actions in a thread prior to submitting a runnableto this method happen-before actions performed by the runnable in the JavaFX Application Thread.- Parameters:
- runnable- the Runnable whose run method will be executed on the JavaFX Application Thread
- Throws:
- IllegalStateException- if the FX runtime has not been initialized
- See Also:
 
- 
requestNextPulsepublic static void requestNextPulse()Requests the Java Runtime to perform a pulse. This will run a pulse even if there are no animation timers, scene graph modifications, or window events that would otherwise cause the pulse to run. If no pulse is in progress, then one will be scheduled to run the next time the pulse timer fires. If there is already a pulse running, then at least one more pulse after the current pulse will be scheduled. This method may be called on any thread.- Since:
- 9
 
- 
isFxApplicationThreadpublic static boolean isFxApplicationThread()Returns true if the calling thread is the JavaFX Application Thread. Use this call to ensure that a given task is being executed (or not being executed) on the JavaFX Application Thread.- Returns:
- true if running on the JavaFX Application Thread
 
- 
exitpublic static void exit()Causes the JavaFX application to terminate. If this method is called after the Application start method is called, then the JavaFX launcher will call the Application stop method and terminate the JavaFX application thread. The launcher thread will then shutdown. If there are no other non-daemon threads that are running, the Java VM will exit. If this method is called from the Preloader or the Application init method, then the Application stop method may not be called.This method may be called from any thread. 
- 
setImplicitExitpublic static void setImplicitExit(boolean implicitExit) Sets the implicitExit attribute to the specified value. If this attribute is true, the JavaFX runtime will implicitly shutdown when the last window is closed; the JavaFX launcher will call theApplication.stop()method and terminate the JavaFX application thread. If this attribute is false, the application will continue to run normally even after the last window is closed, until the application callsexit(). The default value is true.This method may be called from any thread. - Parameters:
- implicitExit- a flag indicating whether or not to implicitly exit when the last window is closed.
- Since:
- JavaFX 2.2
 
- 
isImplicitExitpublic static boolean isImplicitExit()Gets the value of the implicitExit attribute.This method may be called from any thread. - Returns:
- the implicitExit attribute
- Since:
- JavaFX 2.2
 
- 
isSupportedQueries whether a specific conditional feature is supported by the platform.For example: // Query whether filter effects are supported if (Platform.isSupported(ConditionalFeature.EFFECT)) { // use effects }- Parameters:
- feature- the conditional feature in question.
- Returns:
- true if a specific conditional feature is supported by the platform, otherwise false
 
- 
enterNestedEventLoopEnter a nested event loop and block until the corresponding exitNestedEventLoop call is made. The key passed into this method is used to uniquely identify the matched enter/exit pair. This method creates a new nested event loop and blocks until the corresponding exitNestedEventLoop method is called with the same key. The return value of this method will be thervalobject supplied to the exitNestedEventLoop method call that unblocks it.This method must either be called from an input event handler or from the run method of a Runnable passed to Platform.runLater. It must not be called during animation or layout processing.- Parameters:
- key- the Object that identifies the nested event loop, which must not be null
- Returns:
- the value passed into the corresponding call to exitEventLoop
- Throws:
- IllegalArgumentException- if the specified key is associated with a nested event loop that has not yet returned
- NullPointerException- if the key is null
- IllegalStateException- if this method is called during animation or layout processing.
- IllegalStateException- if this method is called on a thread other than the JavaFX Application Thread.
- Since:
- 9
 
- 
exitNestedEventLoopExit a nested event loop and unblock the caller of the corresponding enterNestedEventLoop. The key passed into this method is used to uniquely identify the matched enter/exit pair. This method causes the nested event loop that was previously created with the key to exit and return control to the caller. If the specified nested event loop is not the inner-most loop then it will not return until all other inner loops also exit.- Parameters:
- key- the Object that identifies the nested event loop, which must not be null
- rval- an Object that is returned to the caller of the corresponding enterNestedEventLoop. This may be null.
- Throws:
- IllegalArgumentException- if the specified key is not associated with an active nested event loop
- NullPointerException- if the key is null
- IllegalStateException- if this method is called on a thread other than the FX Application thread
- Since:
- 9
 
- 
isKeyLockedReturns a flag indicating whether the key corresponding tokeyCodeis in the locked (or "on") state.keyCodemust be one of:KeyCode.CAPSorKeyCode.NUM_LOCK. If the underlying system is not able to determine the state of the specifiedkeyCode, an emptyOptionalis returned. If the keyboard attached to the system doesn't have the specified key, anOptionalcontainingfalseis returned. This method must be called on the JavaFX Application thread.- Parameters:
- keyCode- the- KeyCodeof the lock state to query
- Returns:
- the lock state of the key corresponding to keyCode, or an emptyOptionalif the system cannot determine its state
- Throws:
- IllegalArgumentException- if- keyCodeis not one of the valid- KeyCodevalues
- IllegalStateException- if this method is called on a thread other than the JavaFX Application Thread
- Since:
- 17
 
- 
isNestedLoopRunningpublic static boolean isNestedLoopRunning()Checks whether a nested event loop is running, returning true to indicate that one is, and false if there are no nested event loops currently running. This method must be called on the JavaFX Application thread.- Returns:
- true if there is a nested event loop running, and false otherwise.
- Throws:
- IllegalStateException- if this method is called on a thread other than the JavaFX Application Thread.
- Since:
- 9
 
- 
canStartNestedEventLooppublic static boolean canStartNestedEventLoop()Indicates whether a nested event loop can be started from the current thread in the current state. A nested event loop can be started from an event handler or from aRunnablepassed torunLater(Runnable). This method must be called on the JavaFX Application thread.- Returns:
- trueif a nested event loop can be started, and- falseotherwise.
- Throws:
- IllegalStateException- if this method is called on a thread other than the JavaFX Application Thread.
- Since:
- 21
 
- 
isAccessibilityActivepublic static boolean isAccessibilityActive()Gets the value of theaccessibilityActiveproperty.- Property description:
- Indicates whether or not accessibility is active.
 This property is typically set to true the first time an
 assistive technology, such as a screen reader, requests
 information about any JavaFX window or its children.
 This method may be called from any thread. 
- Returns:
- the value of the accessibilityActiveproperty
- Since:
- JavaFX 8u40
- See Also:
 
- 
accessibilityActivePropertyIndicates whether or not accessibility is active. This property is typically set to true the first time an assistive technology, such as a screen reader, requests information about any JavaFX window or its children.This method may be called from any thread. - Returns:
- the read-only boolean property indicating if accessibility is active
- Since:
- JavaFX 8u40
- See Also:
 
- 
getPreferencesGets the preferences of the current platform.The map returned from this method is unmodifiable, which means that keys and values cannot be added, removed, or updated. Calling any mutator method on the map will always cause UnsupportedOperationExceptionto be thrown. However, the mappings will be updated by JavaFX when the operating system reports that a platform preference has changed.- Returns:
- the Preferencesinstance
- Since:
- 22
- See Also:
 
 
-