public void startDrag(DragGestureEvent trigger, Cursor dragCursor, Image dragImage, Point imageOffset, Transferable transferable, DragSourceListener dsl, FlavorMap flavorMap) throws InvalidDnDOperationException { if (curContext != null) { // awt.171=Attempt to start a drag while an existing drag operation is still executing. throw new InvalidDnDOperationException(Messages.getString("awt.171")); //$NON-NLS-1$ } DragSourceContextPeer peer = Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger); curContext = createDragSourceContext(peer, trigger, dragCursor, dragImage, imageOffset, transferable, dsl); peer.startDrag(curContext, dragCursor, dragImage, imageOffset); curContext = null; }
/** * Start a drag, given the <code>DragGestureEvent</code> * that initiated the drag, the initial * <code>Cursor</code> to use, * the <code>Image</code> to drag, * the offset of the <code>Image</code> origin * from the hotspot of the <code>Cursor</code> at * the instant of the trigger, * the <code>Transferable</code> subject data * of the drag, the <code>DragSourceListener</code>, * and the <code>FlavorMap</code>. * <P> * @param trigger the <code>DragGestureEvent</code> that initiated the drag * @param dragCursor the initial {@code Cursor} for this drag operation * or {@code null} for the default cursor handling; * see <a href="DragSourceContext.html#defaultCursor">DragSourceContext</a> * for more details on the cursor handling mechanism during drag and drop * @param dragImage the image to drag or {@code null} * @param imageOffset the offset of the <code>Image</code> origin from the hotspot * of the <code>Cursor</code> at the instant of the trigger * @param transferable the subject data of the drag * @param dsl the <code>DragSourceListener</code> * @param flavorMap the <code>FlavorMap</code> to use, or <code>null</code> * <P> * @throws java.awt.dnd.InvalidDnDOperationException * if the Drag and Drop * system is unable to initiate a drag operation, or if the user * attempts to start a drag while an existing drag operation * is still executing */ public void startDrag(DragGestureEvent trigger, Cursor dragCursor, Image dragImage, Point imageOffset, Transferable transferable, DragSourceListener dsl, FlavorMap flavorMap) throws InvalidDnDOperationException { SunDragSourceContextPeer.setDragDropInProgress(true); try { if (flavorMap != null) this.flavorMap = flavorMap; DragSourceContextPeer dscp = Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger); DragSourceContext dsc = createDragSourceContext(dscp, trigger, dragCursor, dragImage, imageOffset, transferable, dsl ); if (dsc == null) { throw new InvalidDnDOperationException(); } dscp.startDrag(dsc, dsc.getCursor(), dragImage, imageOffset); // may throw } catch (RuntimeException e) { SunDragSourceContextPeer.setDragDropInProgress(false); throw e; } }
@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); }
/** * create the peer for a DragSourceContext */ @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); }
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); }
@Override 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); }
/** * Initializes a drag source context. * * @exception IllegalArgumentException If Component or DragSource of trigger * are null, the drag action for the trigger event is DnDConstants.ACTION_NONE * or if the source actions for the DragGestureRecognizer associated with the * trigger event are equal to DnDConstants.ACTION_NONE. * @exception NullPointerException If peer, trans or trigger is null or if the * image is not null but the offset is. */ public DragSourceContext (DragSourceContextPeer peer, DragGestureEvent trigger, Cursor cursor, Image image, Point offset, Transferable trans, DragSourceListener dsl) { if (peer == null || trigger == null || trans == null || (image != null && offset == null)) throw new NullPointerException (); if (trigger.getComponent () == null || trigger.getDragSource () == null || trigger.getDragAction () == DnDConstants.ACTION_NONE || trigger.getSourceAsDragGestureRecognizer () .getSourceActions () == DnDConstants.ACTION_NONE) throw new IllegalArgumentException (); this.peer = peer; this.trigger = trigger; this.cursor = cursor; this.image = image; this.offset = offset; this.transferable = trans; this.dragSourceListener = dsl; this.sourceActions = trigger.getSourceAsDragGestureRecognizer().getSourceActions(); setCursor(cursor); updateCurrentCursor(trigger.getDragAction(), sourceActions, DEFAULT); }
/** * Creates the DragSourceContext to handle this drag. * * @exception IllegalArgumentException * @exception NullPointerException If dscp, dgl, dragImage or t is null. */ protected DragSourceContext createDragSourceContext(DragSourceContextPeer peer, DragGestureEvent dge, Cursor cursor, Image image, Point offset, Transferable t, DragSourceListener dsl) { return new DragSourceContext(peer, dge, cursor, image, offset, t, dsl); }
/** * Start a drag, given the <code>DragGestureEvent</code> * that initiated the drag, the initial * <code>Cursor</code> to use, * the <code>Image</code> to drag, * the offset of the <code>Image</code> origin * from the hotspot of the <code>Cursor</code> at * the instant of the trigger, * the <code>Transferable</code> subject data * of the drag, the <code>DragSourceListener</code>, * and the <code>FlavorMap</code>. * <P> * @param trigger the <code>DragGestureEvent</code> that initiated the drag * @param dragCursor the initial <code>Cursor</code> or <code>null</code> for defaults * @param dragImage the image to drag or null, * @param imageOffset the offset of the <code>Image</code> origin from the hotspot * of the <code>Cursor</code> at the instant of the trigger * @param transferable the subject data of the drag * @param dsl the <code>DragSourceListener</code> * @param flavorMap the <code>FlavorMap</code> to use, or <code>null</code> * <P> * @throws <code>java.awt.dnd.InvalidDnDOperationException</code> * if the Drag and Drop * system is unable to initiate a drag operation, or if the user * attempts to start a drag while an existing drag operation * is still executing */ public void startDrag(DragGestureEvent trigger, Cursor dragCursor, Image dragImage, Point imageOffset, Transferable transferable, DragSourceListener dsl, FlavorMap flavorMap) throws InvalidDnDOperationException { SunDragSourceContextPeer.setDragDropInProgress(true); try { if (flavorMap != null) this.flavorMap = flavorMap; DragSourceContextPeer dscp = Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger); DragSourceContext dsc = createDragSourceContext(dscp, trigger, dragCursor, dragImage, imageOffset, transferable, dsl ); if (dsc == null) { throw new InvalidDnDOperationException(); } dscp.startDrag(dsc, dsc.getCursor(), dragImage, imageOffset); // may throw } catch (RuntimeException e) { SunDragSourceContextPeer.setDragDropInProgress(false); throw e; } }