--- old/modules/javafx.swing/src/main/java/javafx/embed/swing/FXDnD.java 2018-05-05 14:08:50.455054600 +0530 +++ new/modules/javafx.swing/src/main/java/javafx/embed/swing/FXDnD.java 2018-05-05 14:08:49.737453300 +0530 @@ -44,8 +44,6 @@ import java.awt.dnd.DropTargetListener; import java.awt.dnd.InvalidDnDOperationException; import java.awt.dnd.MouseDragGestureRecognizer; -import java.awt.dnd.peer.DragSourceContextPeer; -import java.awt.dnd.peer.DropTargetContextPeer; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.HashMap; @@ -58,10 +56,11 @@ import javafx.scene.input.Dragboard; import javafx.scene.input.MouseEvent; import javafx.scene.input.TransferMode; -import sun.awt.AWTAccessor; -import sun.awt.dnd.SunDragSourceContextPeer; -import sun.swing.JLightweightFrame; +import jdk.swing.interop.LightweightFrameWrapper; +import jdk.swing.interop.SwingInterOpUtils; +import jdk.swing.interop.DragSourceContextWrapper; +import jdk.swing.interop.DropTargetContextWrapper; /** * A utility class to connect DnD mechanism of Swing and FX. @@ -99,9 +98,8 @@ this.x = xArg; this.y = yArg; - final JLightweightFrame lwFrame = node.getLightweightFrame(); - Component c = AWTAccessor.getContainerAccessor().findComponentAt( - lwFrame, x, y, false); + final LightweightFrameWrapper lwFrame = node.getLightweightFrame(); + Component c = lwFrame.findComponentAt(lwFrame, x, y, false); if (c == null) return; synchronized (c.getTreeLock()) { @@ -114,7 +112,7 @@ //assert c == object.getComponent(); // Translate x, y from lwFrame to component coordinates - while (c != lwFrame && c != null) { + while ((lwFrame.isCompEqual(c,lwFrame)) && c != null) { x -= c.getX(); y -= c.getY(); c = c.getParent(); @@ -197,7 +195,7 @@ // Also, the modifiers here should've actually come from the last known mouse event (last MOVE or DRAG). // But we're OK with using the initial PRESS modifiers for now - int initialAction = SunDragSourceContextPeer.convertModifiersToDropAction( + int initialAction = DragSourceContextWrapper.convertModifiersToDropAction( modifiers, getSourceActions()); fireDragGestureRecognized(initialAction, new java.awt.Point(x, y)); @@ -281,7 +279,7 @@ }; - private final class FXDragSourceContextPeer extends SunDragSourceContextPeer { + private final class FXDragSourceContextPeer extends DragSourceContextWrapper { private volatile int sourceActions = 0; private final CachingTransferable transferable = new CachingTransferable(); @@ -337,6 +335,7 @@ } }; + //@Override public T createDragGestureRecognizer( Class abstractRecognizerClass, DragSource ds, Component c, int srcActions, @@ -345,7 +344,8 @@ return (T) new FXDragGestureRecognizer(ds, c, srcActions, dgl); } - public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException + //@Override + public DragSourceContextWrapper createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException { return new FXDragSourceContextPeer(dge); } @@ -418,7 +418,7 @@ activeDTContextPeer = null; }; - private final class FXDropTargetContextPeer implements DropTargetContextPeer { + private final class FXDropTargetContextPeer extends DropTargetContextWrapper { private int targetActions = DnDConstants.ACTION_NONE; private int currentAction = DnDConstants.ACTION_NONE; @@ -469,7 +469,7 @@ SwingFXUtils.runOnEDTAndWait(FXDnD.this, () -> { if (target != dt) { if (ctx != null) { - AWTAccessor.getDropTargetContextAccessor().reset(ctx); + DropTargetContextWrapper.reset(ctx); } ctx = null; @@ -479,8 +479,8 @@ if (target != null) { if (ctx == null) { ctx = target.getDropTargetContext(); - AWTAccessor.getDropTargetContextAccessor() - .setDropTargetContextPeer(ctx, FXDropTargetContextPeer.this); + DropTargetContextWrapper.setDropTargetContextPeer(ctx, + new FXDropTargetContextPeer()); } DropTargetListener dtl = (DropTargetListener)target;