--- old/modules/javafx.swing/src/main/java/javafx/embed/swing/JFXPanel.java 2018-05-05 14:08:46.663247900 +0530 +++ new/modules/javafx.swing/src/main/java/javafx/embed/swing/JFXPanel.java 2018-05-05 14:08:45.945646600 +0530 @@ -77,13 +77,12 @@ import java.lang.reflect.Method; import java.util.concurrent.atomic.AtomicInteger; -import sun.awt.AppContext; -import sun.awt.SunToolkit; -import sun.java2d.SunGraphics2D; -import sun.java2d.SurfaceData; + import com.sun.javafx.logging.PlatformLogger; import com.sun.javafx.logging.PlatformLogger.Level; +import jdk.swing.interop.SwingInterOpUtils; + /** * {@code JFXPanel} is a component to embed JavaFX content into * Swing applications. The content to be displayed is specified @@ -450,10 +449,7 @@ // component. Fire the same MOUSE_PRESSED event after // requestFocus() so that 2nd mouse press will be honoured // since now fx have focus - AppContext context = SunToolkit.targetToAppContext(this); - if (context != null) { - SunToolkit.postEvent(context, e); - } + SwingInterOpUtils.postEvent(this, e); } } @@ -570,11 +566,8 @@ double newScaleFactorX = scaleFactorX; double newScaleFactorY = scaleFactorY; Graphics g = getGraphics(); - if (g instanceof SunGraphics2D) { - SurfaceData sd = ((SunGraphics2D) g).surfaceData; - newScaleFactorX = sd.getDefaultScaleX(); - newScaleFactorY = sd.getDefaultScaleY(); - } + newScaleFactorX = SwingInterOpUtils.getDefaultScaleX(g); + newScaleFactorY = SwingInterOpUtils.getDefaultScaleY(g); if (oldWidth != pWidth || oldHeight != pHeight || newScaleFactorX != scaleFactorX || newScaleFactorY != scaleFactorY) { @@ -765,11 +758,8 @@ double newScaleFactorX = scaleFactorX; double newScaleFactorY = scaleFactorY; - if (g instanceof SunGraphics2D) { - SurfaceData sd = ((SunGraphics2D)g).surfaceData; - newScaleFactorX = sd.getDefaultScaleX(); - newScaleFactorY = sd.getDefaultScaleY(); - } + newScaleFactorX = SwingInterOpUtils.getDefaultScaleX(g); + newScaleFactorY = SwingInterOpUtils.getDefaultScaleY(g); if (scaleFactorX != newScaleFactorX || scaleFactorY != newScaleFactorY) { createResizePixelBuffer(newScaleFactorX, newScaleFactorY); // The scene will request repaint. @@ -828,7 +818,7 @@ } private transient AWTEventListener ungrabListener = event -> { - if (event instanceof sun.awt.UngrabEvent) { + if (SwingInterOpUtils.isUngrabEvent(event)) { SwingFXUtils.runOnFxThread(() -> { if (JFXPanel.this.stagePeer != null && getScene() != null && @@ -877,7 +867,7 @@ AccessController.doPrivileged((PrivilegedAction) () -> { JFXPanel.this.getToolkit().addAWTEventListener(ungrabListener, - SunToolkit.GRAB_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK); + SwingInterOpUtils.GRAB_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK); return null; }); updateComponentSize(); // see RT-23603 @@ -928,12 +918,7 @@ } private void invokeOnClientEDT(Runnable r) { - AppContext context = SunToolkit.targetToAppContext(this); - if (context == null) { - if (log.isLoggable(Level.FINE)) log.fine("null AppContext encountered!"); - return; - } - SunToolkit.postEvent(context, new InvocationEvent(this, r)); + SwingInterOpUtils.postEvent(this, new InvocationEvent(this, r)); } private class HostContainer implements HostInterface { @@ -1054,9 +1039,7 @@ invokeOnClientEDT(() -> { Window window = SwingUtilities.getWindowAncestor(JFXPanel.this); if (window != null) { - if (JFXPanel.this.getToolkit() instanceof SunToolkit) { - ((SunToolkit)JFXPanel.this.getToolkit()).grab(window); - } + SwingInterOpUtils.grab(JFXPanel.this.getToolkit(), window); } }); @@ -1072,9 +1055,7 @@ invokeOnClientEDT(() -> { Window window = SwingUtilities.getWindowAncestor(JFXPanel.this); if (window != null) { - if (JFXPanel.this.getToolkit() instanceof SunToolkit) { - ((SunToolkit)JFXPanel.this.getToolkit()).ungrab(window); - } + SwingInterOpUtils.ungrab(JFXPanel.this.getToolkit(), window); } }); }