src/java.desktop/share/classes/java/awt/dnd/DragSourceContext.java

Print this page

        

*** 27,51 **** import java.awt.Component; import java.awt.Cursor; import java.awt.Image; import java.awt.Point; ! import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; - import java.awt.dnd.peer.DragSourceContextPeer; - import java.io.IOException; import java.io.InvalidObjectException; - import java.io.ObjectOutputStream; import java.io.ObjectInputStream; import java.io.Serializable; - import java.util.TooManyListenersException; /** * The <code>DragSourceContext</code> class is responsible for managing the * initiator side of the Drag and Drop protocol. In particular, it is responsible * for managing drag event notifications to the * {@linkplain DragSourceListener DragSourceListeners} --- 27,50 ---- import java.awt.Component; import java.awt.Cursor; import java.awt.Image; import java.awt.Point; ! import java.awt.Toolkit; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.dnd.peer.DragSourceContextPeer; import java.io.IOException; import java.io.InvalidObjectException; import java.io.ObjectInputStream; + import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.TooManyListenersException; + import sun.awt.AWTAccessor; + /** * The <code>DragSourceContext</code> class is responsible for managing the * initiator side of the Drag and Drop protocol. In particular, it is responsible * for managing drag event notifications to the * {@linkplain DragSourceListener DragSourceListeners}
*** 121,130 **** --- 120,133 ---- * indicating that the user operation has changed. */ protected static final int CHANGED = 3; + static { + AWTAccessor.setDragSourceContextAccessor(dsc -> dsc.peer); + } + /** * Called from <code>DragSource</code>, this constructor creates a new * <code>DragSourceContext</code> given the * <code>DragSourceContextPeer</code> for this Drag, the * <code>DragGestureEvent</code> that triggered the Drag, the initial
*** 153,163 **** * <code>NullPointerException</code> is thrown. * <br> * If <code>DragSourceListener</code> is <code>null</code> no exception * is thrown. * - * @param dscp the <code>DragSourceContextPeer</code> for this drag * @param trigger the triggering event * @param dragCursor the initial {@code Cursor} for this drag operation * or {@code null} for the default cursor handling; * see <a href="DragSourceContext.html#defaultCursor">class level documentation</a> * for more details on the cursor handling mechanism during drag and drop --- 156,165 ----
*** 177,190 **** * <code>DragGestureRecognizer</code> associated with the trigger * event are equal to <code>DnDConstants.ACTION_NONE</code>. * @throws NullPointerException if dscp, trigger, or t are null, or * if dragImage is non-null and offset is null */ ! public DragSourceContext(DragSourceContextPeer dscp, ! DragGestureEvent trigger, Cursor dragCursor, Image dragImage, Point offset, Transferable t, DragSourceListener dsl) { if (dscp == null) { throw new NullPointerException("DragSourceContextPeer"); } if (trigger == null) { --- 179,194 ---- * <code>DragGestureRecognizer</code> associated with the trigger * event are equal to <code>DnDConstants.ACTION_NONE</code>. * @throws NullPointerException if dscp, trigger, or t are null, or * if dragImage is non-null and offset is null */ ! public DragSourceContext(DragGestureEvent trigger, Cursor dragCursor, Image dragImage, Point offset, Transferable t, DragSourceListener dsl) { + DragSourceContextPeer dscp = Toolkit.getDefaultToolkit() + .createDragSourceContextPeer(trigger); + if (dscp == null) { throw new NullPointerException("DragSourceContextPeer"); } if (trigger == null) {
*** 621,632 **** private static Transferable emptyTransferable; /* * fields */ ! ! private transient DragSourceContextPeer peer; /** * The event which triggered the start of the drag. * * @serial --- 625,635 ---- private static Transferable emptyTransferable; /* * fields */ ! private final transient DragSourceContextPeer peer; /** * The event which triggered the start of the drag. * * @serial