JavaFX IllegalStateException when disposing JFXPanel in Swing

爷,独闯天下 提交于 2019-11-29 17:49:17

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/16867120/javafx-illegalstateexception-when-disposing-jfxpanel-in-swing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!