public final class Platform
extends java.lang.Object
Type | Property and Description |
---|---|
static ReadOnlyBooleanProperty |
accessibilityActive
Indicates whether or not accessibility is active.
|
Modifier and Type | Field and Description |
---|---|
private static ReadOnlyBooleanWrapper |
accessibilityActiveProperty |
Modifier | Constructor and Description |
---|---|
private |
Platform() |
Modifier and Type | Method and Description |
---|---|
static ReadOnlyBooleanProperty |
accessibilityActiveProperty()
Indicates whether or not accessibility is active.
|
static java.lang.Object |
enterNestedEventLoop(java.lang.Object key)
Enter a nested event loop and block until the corresponding
exitNestedEventLoop call is made.
|
static void |
exit()
Causes the JavaFX application to terminate.
|
static void |
exitNestedEventLoop(java.lang.Object key,
java.lang.Object rval)
Exit a nested event loop and unblock the caller of the
corresponding enterNestedEventLoop.
|
static boolean |
isAccessibilityActive()
Gets the value of the property accessibilityActive.
|
static boolean |
isFxApplicationThread()
Returns true if the calling thread is the JavaFX Application Thread.
|
static boolean |
isImplicitExit()
Gets the value of the implicitExit attribute.
|
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.
|
static boolean |
isSupported(ConditionalFeature feature)
Queries whether a specific conditional feature is supported
by the platform.
|
static void |
requestNextPulse()
Requests the Java Runtime to perform a pulse.
|
static void |
runLater(java.lang.Runnable runnable)
Run the specified Runnable on the JavaFX Application Thread at some
unspecified
time in the future.
|
static void |
setImplicitExit(boolean implicitExit)
Sets the implicitExit attribute to the specified value.
|
static void |
startup(java.lang.Runnable runnable)
This method starts the JavaFX runtime.
|
public static ReadOnlyBooleanProperty accessibilityActiveProperty
This method may be called from any thread.
isAccessibilityActive()
private static ReadOnlyBooleanWrapper accessibilityActiveProperty
public static void startup(java.lang.Runnable runnable)
This method may or may not return to the caller before the run method
of the specified Runnable has been called. In any case, 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:
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 the Application
class is loaded.javafx.embed.swing.JFXPanel
to display FX content, the
FX runtime is initialized when the first JFXPanel
instance is
constructed.FXCanvas
to display FX content,
the FX runtime is initialized when the first FXCanvas
instance 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
IllegalStateException
being thrown - it is only valid to request
that the JavaFX runtime be started once.
runnable
- the Runnable whose run method will be executed on the
JavaFX Application Thread once it has been startedjava.lang.IllegalStateException
- if the JavaFX runtime is already runningApplication
public static void runLater(java.lang.Runnable runnable)
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 calling
startup(Runnable)
once.
runnable
- the Runnable whose run method will be executed on the
JavaFX Application Threadjava.lang.IllegalStateException
- if the FX runtime has not been initializedApplication
public static void requestNextPulse()
public static boolean isFxApplicationThread()
public static void exit()
This method may be called from any thread.
public static void setImplicitExit(boolean implicitExit)
Application.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 calls exit()
.
The default value is true.
This method may be called from any thread.
implicitExit
- a flag indicating whether or not to implicitly exit
when the last window is closed.public static boolean isImplicitExit()
This method may be called from any thread.
public static boolean isSupported(ConditionalFeature feature)
For example:
// Query whether filter effects are supported if (Platform.isSupported(ConditionalFeature.EFFECT)) { // use effects }
feature
- the conditional feature in question.public static java.lang.Object enterNestedEventLoop(java.lang.Object key)
rval
object 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.
key
- the Object that identifies the nested event loop, which
must not be nulljava.lang.IllegalArgumentException
- if the specified key is associated
with a nested event loop that has not yet returnedjava.lang.NullPointerException
- if the key is nulljava.lang.IllegalStateException
- if this method is called during
animation or layout processing.java.lang.IllegalStateException
- if this method is called on a thread
other than the JavaFX Application Thread.public static void exitNestedEventLoop(java.lang.Object key, java.lang.Object rval)
key
- the Object that identifies the nested event loop, which
must not be nullrval
- an Object that is returned to the caller of the
corresponding enterNestedEventLoop. This may be null.java.lang.IllegalArgumentException
- if the specified key is not associated
with an active nested event loopjava.lang.NullPointerException
- if the key is nulljava.lang.IllegalStateException
- if this method is called on a thread
other than the FX Application threadpublic static boolean isNestedLoopRunning()
java.lang.IllegalStateException
- if this method is called on a thread
other than the JavaFX Application Thread.public static boolean isAccessibilityActive()
public static ReadOnlyBooleanProperty accessibilityActiveProperty()
This method may be called from any thread.
isAccessibilityActive()