Package de.gsi.chart.utils
Class FXUtils
- java.lang.Object
-
- de.gsi.chart.utils.FXUtils
-
public final class FXUtils extends java.lang.ObjectSmall tool to execute/call JavaFX GUI-related code from potentially non-JavaFX thread (equivalent to old: SwingUtilities.invokeLater(...) ... invokeAndWait(...) tools)- Author:
- rstein
-
-
Constructor Summary
Constructors Constructor Description FXUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidassertJavaFxThread()static voidkeepJavaFxAlive()If you run into any situation where all of your scenes end, the thread managing all of this will just peter out.static voidrunAndWait(java.lang.Runnable function)Invokes a Runnable in JFX Thread and waits while it's finished.static <R> RrunAndWait(java.util.function.Supplier<R> function)Invokes a Runnable in JFX Thread and waits while it's finished.static <T,R>
RrunAndWait(T argument, java.util.function.Function<T,R> function)Invokes a Runnable in JFX Thread and waits while it's finished.static voidrunFX(java.lang.Runnable run)static booleanwaitForFxTicks(javafx.scene.Scene scene, int nTicks)static booleanwaitForFxTicks(javafx.scene.Scene scene, int nTicks, long timeoutMillis)
-
-
-
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 function) throws java.lang.ExceptionInvokes a Runnable in JFX Thread and waits while it's finished. Like SwingUtilities.invokeAndWait does for EDT.- Parameters:
function- Runnable function that should be executed within the JavaFX thread- Throws:
java.lang.Exception- if a exception is occurred in the run method of the Runnable
-
runAndWait
public static <R> R runAndWait(java.util.function.Supplier<R> function) throws java.lang.ExceptionInvokes a Runnable in JFX Thread and waits while it's finished. Like SwingUtilities.invokeAndWait does for EDT.- Type Parameters:
R- generic for return type- Parameters:
function- Supplier function that should be executed within the JavaFX thread- Returns:
- function result of type R
- Throws:
java.lang.Exception- if a exception is occurred in the run method of the Runnable
-
runAndWait
public static <T,R> R runAndWait(T argument, java.util.function.Function<T,R> function) throws java.lang.ExceptionInvokes a Runnable in JFX Thread and waits while it's finished. Like SwingUtilities.invokeAndWait does for EDT.- Type Parameters:
T- generic for argument typeR- generic for return type- Parameters:
argument- function argumentfunction- transform function that should be executed within the JavaFX thread- Returns:
- function result of type R
- Throws:
java.lang.Exception- if a exception is occurred in the run method of the Runnable
-
runFX
public static void runFX(java.lang.Runnable run)
-
waitForFxTicks
public static boolean waitForFxTicks(javafx.scene.Scene scene, int nTicks)
-
waitForFxTicks
public static boolean waitForFxTicks(javafx.scene.Scene scene, int nTicks, long timeoutMillis)
-
-