JavaFX IllegalStateException when disposing JFXPanel in Swing


I've just come across an oddity with JavaFX and Swing.

When disposing a JavaFX Panel that had been added to a JFrame or JPanel, re-adding a new JFXPanel will throw an IllegalStateException: "Platform.exit has been called".

In my case this has happened after I removed some JPanels with JFXPanels inside and then tried to re-add them.

6/7/2013 6:16:09 AM

Accepted Answer

Luckily I found a solution in an Oracle Forum. Link:

In JavaFX 2.2 add the following line in the Main class:


This has done the trick in my application and will hopefully help some of you out there.

5/31/2013 10:51:19 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow