Hi,

I am trying something which I thought would technically be the easiest
way of migrating parts of an existing application from Swing to JFX,
i.e. have a Swing JMenuItem trigger the showing of a JFX stage because
I thought this would technically even be cleaner than to have a swing
dialog containing an JFXPanel.

Doing this results in the following Exception:

java.lang.IllegalStateException: Toolkit not initialized
at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:276)
~[jfxrt.jar:na]
at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:271)
~[jfxrt.jar:na]
at javafx.application.Platform.runLater(Platform.java:78) ~[jfxrt.jar:na]
at 
de.lesspain.mediatool.menu.ToolsSubmenu$1.actionPerformed(ToolsSubmenu.java:20)
~[

javadoc of runLater states:

This method must not be called before the FX runtime has been
initialized. For standard JavaFX applications that extend Application,
and use either the Java launcher or one of the launch methods in the
Application class to launch the application, the FX runtime is
initialized by the launcher before the Application class is loaded.
For Swing applications that use JFXPanel to display FX content, the FX
runtime is initialized when the first JFXPanel instance is
constructed.

So this is consistent. Still I am wondering, why it should not be
supported to just trigger opening a stage from a Swing menu? Either by
Platform.runLater autoinitializing or offering a separate method like
Platform.ensureInitialized().

Am I missing something obvious?

Thanks,

Robert

Reply via email to