diff options
Diffstat (limited to 'java/awt/dnd')
-rw-r--r-- | java/awt/dnd/DragSource.java | 27 | ||||
-rw-r--r-- | java/awt/dnd/DropTarget.java | 17 | ||||
-rw-r--r-- | java/awt/dnd/DropTargetDragEvent.java | 14 |
3 files changed, 51 insertions, 7 deletions
diff --git a/java/awt/dnd/DragSource.java b/java/awt/dnd/DragSource.java index 90b62b5db..2ab748270 100644 --- a/java/awt/dnd/DragSource.java +++ b/java/awt/dnd/DragSource.java @@ -51,7 +51,6 @@ import java.awt.datatransfer.FlavorMap; import java.awt.datatransfer.SystemFlavorMap; import java.awt.datatransfer.Transferable; import java.awt.dnd.peer.DragSourceContextPeer; -import java.awt.event.MouseMotionListener; import java.io.Serializable; import java.util.EventListener; @@ -77,6 +76,8 @@ public class DragSource implements Serializable private transient DragSourceMotionListener dragSourceMotionListener; private static DragSource ds; + private DragSourceContextPeer peer; + private DragSourceContext context; /** * Initializes the drag source. @@ -140,12 +141,17 @@ public class DragSource implements Serializable // it to the peer, passing itself as a parameter. Now, the native system has // access to the Transferable through the context. + // FIXME: Add check to determine if dragging. + try { flavorMap = map; - DragSourceContextPeer peer = Toolkit.getDefaultToolkit(). - createDragSourceContextPeer(trigger); - DragSourceContext context = createDragSourceContext(peer, trigger, + + if (peer == null) + peer = Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger); + + if (context == null) + context = createDragSourceContext(peer, trigger, dragCursor, dragImage, imageOffset, trans, @@ -307,4 +313,17 @@ public class DragSource implements Serializable // Return an empty EventListener array. return (T[]) new EventListener [0]; } + + /** + * TODO + * @return + * + * @since 1.5 + */ + public static int getDragThreshold() + throws NotImplementedException + { + // FIXME: Not implemented. + return 4; + } } // class DragSource diff --git a/java/awt/dnd/DropTarget.java b/java/awt/dnd/DropTarget.java index 2698b1dae..a3650567f 100644 --- a/java/awt/dnd/DropTarget.java +++ b/java/awt/dnd/DropTarget.java @@ -49,6 +49,7 @@ import java.awt.dnd.peer.DropTargetPeer; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.peer.ComponentPeer; +import java.awt.peer.LightweightPeer; import java.io.Serializable; import java.util.EventListener; import java.util.TooManyListenersException; @@ -160,12 +161,15 @@ public class DropTarget if (GraphicsEnvironment.isHeadless ()) throw new HeadlessException (); - component = c; - actions = i; + setComponent(c); + setDefaultActions(i); dropTargetListener = dtl; flavorMap = fm; setActive (b); + + if (c != null) + c.setDropTarget(this); } /** @@ -275,9 +279,16 @@ public class DropTarget public void addNotify(ComponentPeer p) { + Component c = component; + while (c != null && p instanceof LightweightPeer) + { + p = c.getPeer(); + c = c.getParent(); + } + if (p instanceof DropTargetPeer) { - peer = (DropTargetPeer) p; + peer = ((DropTargetPeer) p); peer.addDropTarget(this); } else diff --git a/java/awt/dnd/DropTargetDragEvent.java b/java/awt/dnd/DropTargetDragEvent.java index ea5b682d1..838141ec3 100644 --- a/java/awt/dnd/DropTargetDragEvent.java +++ b/java/awt/dnd/DropTargetDragEvent.java @@ -40,6 +40,7 @@ package java.awt.dnd; import java.awt.Point; import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; import java.util.List; /** @@ -136,4 +137,17 @@ public class DropTargetDragEvent extends DropTargetEvent { context.rejectDrag (); } + + /** + * TODO + * + * @return + * + * @since 1.5 + */ + public Transferable getTransferable() + { + // FIXME: Not implemented + return null; + } } // class DropTargetDragEvent |