11

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.

mKorbel
  • 109,525
  • 20
  • 134
  • 319
TomDK
  • 1,321
  • 11
  • 16

1 Answers1

22

Luckily I found a solution in an Oracle Forum. Link: https://kr.forums.oracle.com/forums/thread.jspa?threadID=2393986

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

Platform.setImplicitExit(false);

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

TomDK
  • 1,321
  • 11
  • 16
  • I ran in this problem as well and implemented your solution: http://stackoverflow.com/questions/25193198/prevent-javafx-thread-from-dying-with-jfxpanel-swing-interop – jenglert Nov 25 '14 at 15:31