Class PlatformHelper

java.lang.Object
com.dua3.utility.fx.PlatformHelper

public final class PlatformHelper extends Object
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 Details

    • runAndWait

      public static void runAndWait(Runnable action)
      Run a task on the JavaFX application thread and wait for completion. Consider using runLater(Runnable) to avoid executing tasks out of order.
      Parameters:
      action - the task to run
      Throws:
      NullPointerException - if action is null
    • runAndWait

      public static <T extends @Nullable Object> T runAndWait(Supplier<T> action)
      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 - if action is null
    • runLater

      public static void runLater(Runnable action)
      Run a task on the JavaFX application thread.
      Parameters:
      action - the task to run
      Throws:
      NullPointerException - if action is null
    • checkApplicationThread

      public static void checkApplicationThread()
      Checks if the current thread is the FX Application Thread. Throws an exception if it is not.