--- old/src/macosx/classes/sun/lwawt/LWLightweightFramePeer.java 2014-07-18 18:28:47.955156000 +0400 +++ new/src/macosx/classes/sun/lwawt/LWLightweightFramePeer.java 2014-07-18 18:28:46.841092300 +0400 @@ -94,10 +94,12 @@ @Override public void addDropTarget(DropTarget dt) { + getLwTarget().addDropTarget(dt); } @Override public void removeDropTarget(DropTarget dt) { + getLwTarget().removeDropTarget(dt); } @Override --- old/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java 2014-07-18 18:28:54.215514100 +0400 +++ new/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java 2014-07-18 18:28:52.970442900 +0400 @@ -687,6 +687,11 @@ @Override public DragSourceContextPeer createDragSourceContextPeer( DragGestureEvent dge) throws InvalidDnDOperationException { + final LightweightFrame f = SunToolkit.getLightweightFrame(dge.getComponent()); + if (f != null) { + return f.createDragSourceContextPeer(dge); + } + return CDragSourceContextPeer.createDragSourceContextPeer(dge); } @@ -694,6 +699,11 @@ public T createDragGestureRecognizer( Class abstractRecognizerClass, DragSource ds, Component c, int srcActions, DragGestureListener dgl) { + final LightweightFrame f = SunToolkit.getLightweightFrame(c); + if (f != null) { + return f.createDragGestureRecognizer(abstractRecognizerClass, ds, c, srcActions, dgl); + } + DragGestureRecognizer dgr = null; // Create a new mouse drag gesture recognizer if we have a class match: --- old/src/share/classes/sun/awt/LightweightFrame.java 2014-07-18 18:29:00.290861600 +0400 +++ new/src/share/classes/sun/awt/LightweightFrame.java 2014-07-18 18:28:59.093793100 +0400 @@ -25,6 +25,7 @@ package sun.awt; +import java.awt.Component; import java.awt.Container; import java.awt.Frame; import java.awt.Graphics; @@ -33,6 +34,13 @@ import java.awt.MenuComponent; import java.awt.Rectangle; import java.awt.Toolkit; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragGestureRecognizer; +import java.awt.dnd.DragSource; +import java.awt.dnd.DropTarget; +import java.awt.dnd.InvalidDnDOperationException; +import java.awt.dnd.peer.DragSourceContextPeer; import java.awt.peer.FramePeer; /** @@ -169,4 +177,27 @@ hostW = w; hostH = h; } + + /** + * Create a drag gesture recognizer for the lightweight frame. + */ + public abstract T createDragGestureRecognizer( + Class abstractRecognizerClass, + DragSource ds, Component c, int srcActions, + DragGestureListener dgl); + + /** + * Create a drag source context peer for the lightweight frame. + */ + public abstract DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException; + + /** + * Adds a drop target to the lightweight frame. + */ + public abstract void addDropTarget(DropTarget dt); + + /** + * Removes a drop target from the lightweight frame. + */ + public abstract void removeDropTarget(DropTarget dt); } --- old/src/share/classes/sun/awt/SunToolkit.java 2014-07-18 18:29:06.178198300 +0400 +++ new/src/share/classes/sun/awt/SunToolkit.java 2014-07-18 18:29:05.045133500 +0400 @@ -2018,6 +2018,19 @@ return isInstanceOf(cls.getSuperclass(), type); } + protected static LightweightFrame getLightweightFrame(Component c) { + for (; c != null; c = c.getParent()) { + if (c instanceof LightweightFrame) { + return (LightweightFrame)c; + } + if (c instanceof Window) { + // Don't traverse owner windows + return null; + } + } + return null; + } + /////////////////////////////////////////////////////////////////////////// // // The following methods help set and identify whether a particular --- old/src/share/classes/sun/swing/JLightweightFrame.java 2014-07-18 18:29:12.547562600 +0400 +++ new/src/share/classes/sun/swing/JLightweightFrame.java 2014-07-18 18:29:11.320492500 +0400 @@ -37,6 +37,13 @@ import java.awt.Point; import java.awt.Rectangle; import java.awt.Window; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragGestureRecognizer; +import java.awt.dnd.DragSource; +import java.awt.dnd.DropTarget; +import java.awt.dnd.InvalidDnDOperationException; +import java.awt.dnd.peer.DragSourceContextPeer; import java.awt.event.ContainerEvent; import java.awt.event.ContainerListener; import java.awt.image.BufferedImage; @@ -472,4 +479,27 @@ content.setCursor(target.getCursor()); } } + + public T createDragGestureRecognizer( + Class abstractRecognizerClass, + DragSource ds, Component c, int srcActions, + DragGestureListener dgl) + { + return content == null ? null : content.createDragGestureRecognizer( + abstractRecognizerClass, ds, c, srcActions, dgl); + } + + public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException { + return content == null ? null : content.createDragSourceContextPeer(dge); + } + + public void addDropTarget(DropTarget dt) { + if (content == null) return; + content.addDropTarget(dt); + } + + public void removeDropTarget(DropTarget dt) { + if (content == null) return; + content.removeDropTarget(dt); + } } --- old/src/share/classes/sun/swing/LightweightContent.java 2014-07-18 18:29:18.685913700 +0400 +++ new/src/share/classes/sun/swing/LightweightContent.java 2014-07-18 18:29:17.437842400 +0400 @@ -26,7 +26,15 @@ package sun.swing; import javax.swing.JComponent; +import java.awt.Component; import java.awt.Cursor; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragGestureRecognizer; +import java.awt.dnd.DragSource; +import java.awt.dnd.DropTarget; +import java.awt.dnd.InvalidDnDOperationException; +import java.awt.dnd.peer.DragSourceContextPeer; /** * The interface by means of which the {@link JLightweightFrame} class @@ -209,4 +217,33 @@ * @param cursor a cursor to set */ default public void setCursor(Cursor cursor) { } + + /** + * Create a drag gesture recognizer for the lightweight frame. + */ + default public T createDragGestureRecognizer( + Class abstractRecognizerClass, + DragSource ds, Component c, int srcActions, + DragGestureListener dgl) + { + return null; + } + + /** + * Create a drag source context peer for the lightweight frame. + */ + default public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException + { + return null; + } + + /** + * Adds a drop target to the lightweight frame. + */ + default public void addDropTarget(DropTarget dt) {} + + /** + * Removes a drop target from the lightweight frame. + */ + default public void removeDropTarget(DropTarget dt) {} } --- old/src/solaris/classes/sun/awt/X11/XLightweightFramePeer.java 2014-07-18 18:29:24.855266600 +0400 +++ new/src/solaris/classes/sun/awt/X11/XLightweightFramePeer.java 2014-07-18 18:29:23.689199900 +0400 @@ -26,6 +26,7 @@ package sun.awt.X11; import java.awt.Graphics; +import java.awt.dnd.DropTarget; import sun.awt.LightweightFrame; import sun.swing.JLightweightFrame; @@ -69,4 +70,14 @@ public void updateCursorImmediately() { SwingAccessor.getJLightweightFrameAccessor().updateCursor((JLightweightFrame)getLwTarget()); } + + @Override + public void addDropTarget(DropTarget dt) { + getLwTarget().addDropTarget(dt); + } + + @Override + public void removeDropTarget(DropTarget dt) { + getLwTarget().removeDropTarget(dt); + } } --- old/src/solaris/classes/sun/awt/X11/XToolkit.java 2014-07-18 18:29:30.835608700 +0400 +++ new/src/solaris/classes/sun/awt/X11/XToolkit.java 2014-07-18 18:29:29.649540800 +0400 @@ -927,6 +927,11 @@ } public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException { + final LightweightFrame f = SunToolkit.getLightweightFrame(dge.getComponent()); + if (f != null) { + return f.createDragSourceContextPeer(dge); + } + return XDragSourceContextPeer.createDragSourceContextPeer(dge); } @@ -938,6 +943,11 @@ int srcActions, DragGestureListener dgl) { + final LightweightFrame f = SunToolkit.getLightweightFrame(c); + if (f != null) { + return f.createDragGestureRecognizer(recognizerClass, ds, c, srcActions, dgl); + } + if (MouseDragGestureRecognizer.class.equals(recognizerClass)) return (T)new XMouseDragGestureRecognizer(ds, c, srcActions, dgl); else --- old/src/windows/classes/sun/awt/windows/WLightweightFramePeer.java 2014-07-18 18:29:37.311979100 +0400 +++ new/src/windows/classes/sun/awt/windows/WLightweightFramePeer.java 2014-07-18 18:29:36.113910600 +0400 @@ -27,6 +27,7 @@ import java.awt.Component; import java.awt.Graphics; +import java.awt.dnd.DropTarget; import java.awt.event.ComponentEvent; import java.awt.event.MouseEvent; @@ -94,4 +95,14 @@ public boolean isLightweightFramePeer() { return true; } + + @Override + public void addDropTarget(DropTarget dt) { + getLwTarget().addDropTarget(dt); + } + + @Override + public void removeDropTarget(DropTarget dt) { + getLwTarget().removeDropTarget(dt); + } } --- old/src/windows/classes/sun/awt/windows/WToolkit.java 2014-07-18 18:29:43.147312800 +0400 +++ new/src/windows/classes/sun/awt/windows/WToolkit.java 2014-07-18 18:29:42.054250300 +0400 @@ -839,6 +839,11 @@ @Override public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException { + final LightweightFrame f = SunToolkit.getLightweightFrame(dge.getComponent()); + if (f != null) { + return f.createDragSourceContextPeer(dge); + } + return WDragSourceContextPeer.createDragSourceContextPeer(dge); } @@ -849,6 +854,11 @@ DragSource ds, Component c, int srcActions, DragGestureListener dgl) { + final LightweightFrame f = SunToolkit.getLightweightFrame(c); + if (f != null) { + return f.createDragGestureRecognizer(abstractRecognizerClass, ds, c, srcActions, dgl); + } + if (MouseDragGestureRecognizer.class.equals(abstractRecognizerClass)) return (T)new WMouseDragGestureRecognizer(ds, c, srcActions, dgl); else