Package com.dua3.utility.fx
Class PlatformHelper
java.lang.Object
com.dua3.utility.fx.PlatformHelper
The PlatformHelper class provides utility methods for performing tasks on the JavaFX application thread.
It provides methods for running tasks synchronously or asynchronously on the JavaFX application thread,
as well as checking if the current thread is the FX Application Thread.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidChecks if the current thread is the FX Application Thread.static voidrunAndWait(Runnable action) Run a task on the JavaFX application thread and wait for completion.static <T extends @Nullable Object>
TrunAndWait(Supplier<T> action) Run a task on the JavaFX application thread and return result.static voidRun a task on the JavaFX application thread.
-
Method Details
-
runAndWait
Run a task on the JavaFX application thread and wait for completion. Consider usingrunLater(Runnable)to avoid executing tasks out of order.- Parameters:
action- the task to run- Throws:
NullPointerException- ifactionisnull
-
runAndWait
Run a task on the JavaFX application thread and return result.- Type Parameters:
T- the result type- Parameters:
action- the task to run- Returns:
- the result returned by action
- Throws:
NullPointerException- ifactionisnull
-
runLater
Run a task on the JavaFX application thread.- Parameters:
action- the task to run- Throws:
NullPointerException- ifactionisnull
-
checkApplicationThread
public static void checkApplicationThread()Checks if the current thread is the FX Application Thread. Throws an exception if it is not.
-