diff --git a/javafx-embed-swing/src/javafx/embed/swing/JFXPanel.java b/javafx-embed-swing/src/javafx/embed/swing/JFXPanel.java --- a/javafx-embed-swing/src/javafx/embed/swing/JFXPanel.java +++ b/javafx-embed-swing/src/javafx/embed/swing/JFXPanel.java @@ -115,6 +115,7 @@ public class JFXPanel extends JComponent { private static PlatformImpl.FinishListener finishListener; + private static boolean firstPanelShown = false; private HostContainer hostContainer; @@ -162,6 +163,9 @@ // Need to install a finish listener to catch calls to Platform.exit finishListener = new PlatformImpl.FinishListener() { @Override public void idle() { + if (!firstPanelShown) { + return; + } PlatformImpl.removeListener(finishListener); finishListener = null; Platform.exit(); @@ -260,6 +264,7 @@ stage.setScene(newScene); if (!stage.isShowing()) { stage.show(); + firstPanelShown = true; } } }