简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM