I upgraded from Java 10 to Java 12 and JavaFX 12.
Now I can't compile my project anymore because javafx.embed.swingSwingFXUtils
is no longer recognized.
Intellij can't find any library for the class. Seems like javafx.embed
doesn't exist anymore.
I looked to see if the package was dropped but I couldn't find any information regarding it.
Adding JavaFX Content to a Swing ComponentCreating an instance of the JFXPanel class implicitly starts the JavaFX runtime. After the GUI is created, call the initFX method to create the JavaFX scene on the JavaFX application thread.
The JavaFX package is not included in JDK 9 and later. You need to install JDK 8, or you can add the JavaFX package separately, for example, from JDK 8 ( jfxrt. jar ).
As its already been said, it is possible to mix Swing and JavaFX especially since Java 8 you can do it both ways: Embed Swing Components in JavaFX with SwingNode.
The module javafx.swing needs to be included in the gradle file:
javafx {
modules = [ 'javafx.controls', 'javafx.graphics', 'javafx.swing', 'javafx.base' ]
}
In my case, a file called module-info.java was generated in the same package. There I had to add
requires javafx.swing;
When building again, the class was found.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With