5

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();
}
Community
  • 1
  • 1
Cheok Yan Cheng
  • 47,586
  • 132
  • 466
  • 875
  • This is actually a very good question - the interaction between JFX application thread and Swing is messy, to say the least. – Kevin Day Jun 27 '14 at 21:51

0 Answers0