4

I've got an extensive Java (JDK 20) Swing project in the NetBeans IDE that I'd like to add JavaFX 20 to. Specifically I want to use a JFXPanel in a Swing JDialog form.

I've tried adding the JFX library jar files to my project library classpath, and the result appears to build OK. But when I run it, I get this error message:

WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @36d4b5c' Graphics Device initialization failed for : es2, sw

Does anyone know how to do this correctly?

mstoreysmith
  • 81
  • 1
  • 5
  • 4
    JavaFX is [modularized](https://en.wikipedia.org/wiki/Java_Platform_Module_System). – Basil Bourque Aug 04 '23 at 16:03
  • 2
    Follow [_Getting Started with JavaFX_](https://openjfx.io/openjfx-docs/) to create a new project, for [example](https://stackoverflow.com/a/73611827/230513); the guide shows how to modify a project's library properties; I'd also recommend that you prototype your use-case, for [example](https://stackoverflow.com/search?q=%5Bjavafx%5D+JFXPanel+JDialog), in a separate project. – trashgod Aug 04 '23 at 16:59
  • 1
    Make sure the _native_ JavaFX code for your platform is included. If you're using the JavaFX SDK, then that native code is in the `bin` directory. The JavaFX JARs from Maven Central embed the native code. And that warning is likely unrelated to the error; see https://stackoverflow.com/q/67854139/6395627. – Slaw Aug 04 '23 at 20:31
  • 2
    See [integrating JavaFX 8 into swing applications](https://docs.oracle.com/javase/8/javafx/interoperability-tutorial/swing-fx-interoperability.htm) on the code required to integrate JavaFX and Swing. If using Java 8, you can follow the referenced guide exactly. However, as you are using a modern Java version, you will have to do some things differently, as per comments. [`javafx.swing`](https://openjfx.io/javadoc/20/javafx.swing/module-summary.html) is the module you need to add to your module path to use JavaFX with Swing. – jewelsea Aug 04 '23 at 22:10

0 Answers0