Class FXUtils
java.lang.Object
org.testfx.framework.junit5.utils.FXUtils
Small tool to execute/call JavaFX GUI-related code from potentially non-JavaFX thread (equivalent to old:
SwingUtilities.invokeLater(...) ... invokeAndWait(...) tools)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
private static class
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
static void
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
(Runnable function) Invokes a Runnable in JFX Thread and waits while it's finished.static <R> R
runAndWait
(Supplier<R> function) Invokes a Runnable in JFX Thread and waits while it's finished.static <T,
R> R runAndWait
(T argument, Function<T, R> function) Invokes a Runnable in JFX Thread and waits while it's finished.static void
-
Constructor Details
-
FXUtils
public FXUtils()
-
-
Method Details
-
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
Invokes 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:
Exception
- if a exception is occurred in the run method of the Runnable
-
runAndWait
Invokes 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:
Exception
- if a exception is occurred in the run method of the Runnable
-
runAndWait
Invokes 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:
Exception
- if a exception is occurred in the run method of the Runnable
-
runFX
-