--- old/modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/GtkWindow.java 2017-09-21 15:24:44.000000000 +0530 +++ new/modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/GtkWindow.java 2017-09-21 15:24:44.000000000 +0530 @@ -228,4 +228,9 @@ protected void _releaseInput(long ptr) { throw new UnsupportedOperationException("Not supported yet."); } + + @Override + public long getRawHandle() { + return getNativeWindow(); + } } --- old/modules/javafx.swing/src/main/java/javafx/embed/swing/SwingNode.java 2017-09-21 15:24:45.000000000 +0530 +++ new/modules/javafx.swing/src/main/java/javafx/embed/swing/SwingNode.java 2017-09-21 15:24:44.000000000 +0530 @@ -74,12 +74,14 @@ import com.sun.javafx.sg.prism.NGNode; import com.sun.javafx.stage.FocusUngrabEvent; import com.sun.javafx.stage.WindowHelper; +import com.sun.javafx.tk.TKStage; import com.sun.javafx.PlatformUtil; import com.sun.javafx.embed.swing.SwingNodeHelper; import com.sun.javafx.scene.NodeHelper; import sun.awt.UngrabEvent; import sun.swing.JLightweightFrame; import sun.swing.LightweightContent; +import sun.swing.SwingAccessor; /** * This class is used to embed a Swing content into a JavaFX application. @@ -199,6 +201,18 @@ javafx.scene.text.Font.getFamilies(); } + private void notifyNativeHandle(Window window) { + long rawHandle = 0L; + if (window != null) { + TKStage tkStage = WindowHelper.getPeer(window); + if (tkStage != null) { + rawHandle = tkStage.getRawHandle(); + } + } + SwingAccessor.getJLightweightFrameAccessor() + .overrideNativeWindowHandle(lwFrame, rawHandle); + } + /** * Attaches a {@code JComponent} instance to display in this {@code SwingNode}. *

@@ -327,6 +341,10 @@ lwFrame.setContent(new SwingNodeContent(content)); lwFrame.setVisible(true); + if (getScene() != null) { + notifyNativeHandle(getScene().getWindow()); + } + SwingFXUtils.runOnFxThread(() -> { locateLwFrame(); // initialize location @@ -515,6 +533,9 @@ if (oldValue != null) { removeWindowListeners(oldValue); } + + notifyNativeHandle(newValue); + if (newValue != null) { addWindowListeners(newValue); } @@ -532,6 +553,7 @@ Window window = scene.getWindow(); if (window != null) { addWindowListeners(window); + notifyNativeHandle(window); } scene.windowProperty().addListener(sceneWindowListener); }