Class FXUtils


  • public final class FXUtils
    extends java.lang.Object
    Small tool to execute/call JavaFX GUI-related code from potentially non-JavaFX thread (equivalent to old: SwingUtilities.invokeLater(...) ... invokeAndWait(...) tools)
    Author:
    rstein
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void assertJavaFxThread()  
      static void keepJavaFxAlive()
      If you run into any situation where all of your scenes end, the thread managing all of this will just peter out.
      static void runAndWait​(java.lang.Runnable run)
      Invokes a Runnable in JFX Thread and waits while it's finished.
      static void runFX​(java.lang.Runnable run)  
      static void runLater​(java.lang.Runnable run)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • assertJavaFxThread

        public static void assertJavaFxThread()
      • keepJavaFxAlive

        public static void keepJavaFxAlive()
        If you run into any situation where all of your scenes end, the thread managing all of this will just peter out. To prevent this from happening, add this line:
      • runAndWait

        public static void runAndWait​(java.lang.Runnable run)
                               throws java.lang.InterruptedException,
                                      java.util.concurrent.ExecutionException
        Invokes a Runnable in JFX Thread and waits while it's finished. Like SwingUtilities.invokeAndWait does for EDT.
        Parameters:
        run - The Runnable that has to be called on JFX thread.
        Throws:
        java.lang.InterruptedException - if the execution is interrupted.
        java.util.concurrent.ExecutionException - if a exception is occurred in the run method of the Runnable
      • runFX

        public static void runFX​(java.lang.Runnable run)
      • runLater

        public static void runLater​(java.lang.Runnable run)
                             throws java.util.concurrent.ExecutionException
        Throws:
        java.util.concurrent.ExecutionException