I have a large Java application with a Swing-based UI that uses JavaFX to render video panels and WebView panels in parts of some windows via JFXPanel components.
Everything worked fine with JDK 8 but I am migrating to OpenJDK 12 and JavaFX 12 and am getting a runtime exception when creating a JFXPanel. When I call "new JFXPanel()" I am getting the exception:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalAccessError: class
javafx.embed.swing.JFXPanel (in unnamed module @0x44bebd15) cannot access
class com.sun.javafx.logging.PlatformLogger (in module javafx.base) because
module javafx.base does not export com.sun.javafx.logging to unnamed module
@0x44bebd15
The javafx.base and javafx.swing jar files from javafx-sdk-12.0.2 are included in my Eclipse project and runtime (along with a few other JavaFX jars).
I am using VM arguments: --module-path /Library/Java/javafx-sdk-12.0.2/lib --add-modules javafx.controls,javafx.web,javafx.media,javafx.base
Is this a bug in JavaFX 12 or am I doing something wrong?
htmlPanel = new JFXPanel() {
public Dimension getPreferredSize() {
return new Dimension(CoreDrawer.scaledSize(width),
CoreDrawer.scaledSize(height));
}
public Dimension getMinimumSize()
{
return getPreferredSize();
}
};
Platform.runLater(new Runnable() { // run on the JavaFX thread
public void run() {
initFX(htmlPanel);
}
});
Platform.setImplicitExit(false);
thePanel.add(htmlPanel);
The function initFX() adds a Scene to the JFXPanel but the program does not get past "new JFXPanel()"
Comment 'Use --add-modules javafx.web,javafx.media,javafx.swing' by Slaw worked for me. Needed to append javafx.swing to 'VM options' of my run configuration.