Currently, I'm integrating JavaFX into Swing.
I need to use Platform.setImplicitExit(false)
, due to JavaFX IllegalStateException when disposing JFXPanel in Swing
public class MainFrame extends javax.swing.JFrame {
private void formWindowClosed(java.awt.event.WindowEvent evt) {
Platform.exit();
}
public static void main(String args[]) {
Platform.setImplicitExit(false);
}
}
I was wondering, should I avoid recreating JFXPanel
then, every-times I want to show the JDialog
which owns the JFXPanel
? To avoid possible JavaFX resource leakage, should I use
public class SimpleSwingBrowser extends JDialog {
// Avoid JFXPanel re-creation.
private static final JFXPanel jfxPanel = new JFXPanel();
}
or
public class SimpleSwingBrowser extends JDialog {
private final JFXPanel jfxPanel = new JFXPanel();
}