@@ -153,6 +153,7 @@ public class JFXPanel extends JComponent {
153153 // Set in FX thread and accessed in EDT/FX threads
154154 private transient volatile EmbeddedWindow stage ;
155155
156+ // Set and accessed in FX thread only
156157 private transient volatile Scene scene ;
157158
158159 // Accessed on EDT only
@@ -963,15 +964,14 @@ private void setFxEnabled(boolean enabled) {
963964 }
964965
965966 private transient AWTEventListener ungrabListener = event -> {
966- var hStagePeer = JFXPanel .this .stagePeer ;
967967
968968 if (jfxPanelIOP .isUngrabEvent (event )) {
969969 SwingNodeHelper .runOnFxThread (() -> {
970- if (hStagePeer != null &&
970+ if (JFXPanel . this . stagePeer != null &&
971971 getScene () != null &&
972972 getScene ().getFocusOwner () != null &&
973973 getScene ().getFocusOwner ().isFocused ()) {
974- hStagePeer .focusUngrab ();
974+ JFXPanel . this . stagePeer .focusUngrab ();
975975 }
976976 });
977977 }
@@ -985,15 +985,15 @@ private void setFxEnabled(boolean enabled) {
985985
986986 if (jfxPanelWindow == eventWindow ) {
987987 SwingNodeHelper .runOnFxThread (() -> {
988- if (hStagePeer != null ) {
988+ if (JFXPanel . this . stagePeer != null ) {
989989 // No need to check if grab is active or not.
990990 // NoAutoHide popups don't request the grab and
991991 // ignore the Ungrab event anyway.
992992 // AutoHide popups actually should be hidden when
993993 // user clicks some non-FX content, even if for
994994 // some reason they didn't install the grab when
995995 // they were shown.
996- hStagePeer .focusUngrab ();
996+ JFXPanel . this . stagePeer .focusUngrab ();
997997 }
998998 });
999999 }
@@ -1019,8 +1019,8 @@ public void addNotify() {
10191019 if ((stage != null ) && !stage .isShowing ()) {
10201020 stage .show ();
10211021 }
1022+ SwingNodeHelper .runOnEDT (() -> sendMoveEventToFX ());
10221023 });
1023- sendMoveEventToFX ();
10241024 }
10251025
10261026 @ Override
0 commit comments