This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


java.awt.dnd
class DragSourceContext

java.lang.Object extended by java.awt.dnd.DragSourceContext
All Implemented Interfaces:
DragSourceListener, DragSourceMotionListener, Serializable

Most common way to construct:

DragSourceDragEvent e = …;

DragSourceContext ctx = e.getDragSourceContext();

Based on 14 examples


public class DragSourceContext
extends Object
implements DragSourceListener, DragSourceMotionListener, Serializable

The DragSourceContext 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 DragSourceListeners and DragSourceMotionListeners, and providing the Transferable representing the source data for the drag operation.

Note that the DragSourceContext itself implements the DragSourceListener and DragSourceMotionListener interfaces. This is to allow the platform peer (the DragSourceContextPeer instance) created by the DragSource to notify the DragSourceContext of state changes in the ongoing operation. This allows the DragSourceContext to interpose itself between the platform and the listeners provided by the initiator of the drag operation.


Field Summary
protected static int CHANGED
          An int used by updateCurrentCursor() indicating that the user operation has changed.
protected static int DEFAULT
          An int used by updateCurrentCursor() indicating that the Cursor should change to the default (no drop) Cursor.
protected static int ENTER
          An int used by updateCurrentCursor() indicating that the Cursor has entered a DropTarget.
protected static int OVER
          An int used by updateCurrentCursor() indicating that the Cursor is over a DropTarget.
 
Constructor Summary
DragSourceContext(DragSourceContextPeer dscp, DragGestureEvent trigger, Cursor dragCursor, Image dragImage, Point offset, Transferable t, DragSourceListener dsl)

          Called from DragSource, this constructor creates a new DragSourceContext given the DragSourceContextPeer for this Drag, the DragGestureEvent that triggered the Drag, the initial Cursor to use for the Drag, an (optional) Image to display while the Drag is taking place, the offset of the Image origin from the hotspot at the instant of the triggering event, the Transferable subject data, and the DragSourceListener to use during the Drag and Drop operation.
 
Method Summary
 void

          Add a DragSourceListener to this DragSourceContext if one has not already been added.
 void

          Calls dragDropEnd on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceDropEvent.
 void

          Calls dragEnter on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceDragEvent.
 void

          Calls dragExit on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceEvent.
 void

          Calls dragMouseMoved on the DragSourceMotionListeners registered with the DragSource associated with this DragSourceContext, and them passes the specified DragSourceDragEvent.
 void

          Calls dragOver on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceDragEvent.
 void

          Calls dropActionChanged on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceDragEvent.
 Component

          Returns the Component associated with this DragSourceContext.
 Cursor

          Returns the current drag Cursor.
 DragSource

          Returns the DragSource that instantiated this DragSourceContext.
 int

          Returns a bitwise mask of DnDConstants that represent the set of drop actions supported by the drag source for the drag operation associated with this DragSourceContext.
 Transferable

          Returns the Transferable associated with this DragSourceContext.
 DragGestureEvent

          Returns the DragGestureEvent that initially triggered the drag.
 void

          Removes the specified DragSourceListener from this DragSourceContext.
 void

          Sets the cursor for this drag operation to the specified Cursor.
 void

          Notifies the peer that the Transferable's DataFlavors have changed.
protected void
updateCurrentCursor(int sourceAct, int targetAct, int status)

          If the default drag cursor behavior is active, this method sets the default drag cursor for the specified actions supported by the drag source, the drop target action, and status, otherwise this method does nothing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHANGED

protected static final int CHANGED
An int used by updateCurrentCursor() indicating that the user operation has changed.

DEFAULT

protected static final int DEFAULT
An int used by updateCurrentCursor() indicating that the Cursor should change to the default (no drop) Cursor.

ENTER

protected static final int ENTER
An int used by updateCurrentCursor() indicating that the Cursor has entered a DropTarget.

OVER

protected static final int OVER
An int used by updateCurrentCursor() indicating that the Cursor is over a DropTarget.
Constructor Detail

DragSourceContext

public DragSourceContext(DragSourceContextPeer dscp,
                         DragGestureEvent trigger,
                         Cursor dragCursor,
                         Image dragImage,
                         Point offset,
                         Transferable t,
                         DragSourceListener dsl)
Called from DragSource, this constructor creates a new DragSourceContext given the DragSourceContextPeer for this Drag, the DragGestureEvent that triggered the Drag, the initial Cursor to use for the Drag, an (optional) Image to display while the Drag is taking place, the offset of the Image origin from the hotspot at the instant of the triggering event, the Transferable subject data, and the DragSourceListener to use during the Drag and Drop operation.
If DragSourceContextPeer is null NullPointerException is thrown.
If DragGestureEvent is null NullPointerException is thrown.
If Cursor is null no exception is thrown and the default drag cursor behavior is activated for this drag operation.
If Image is null no exception is thrown.
If Image is not null and the offset is null NullPointerException is thrown.
If Transferable is null NullPointerException is thrown.
If DragSourceListener is null no exception is thrown.

Parameters:
dscp - the DragSourceContextPeer for this drag
trigger - the triggering event
dragCursor - the initial Cursor
dragImage - the Image to drag (or null)
offset - the offset of the image origin from the hotspot at the instant of the triggering event
t - the Transferable
dsl - the DragSourceListener
Method Detail

addDragSourceListener

public synchronized void addDragSourceListener(DragSourceListener dsl)
                                        throws TooManyListenersException
Add a DragSourceListener to this DragSourceContext if one has not already been added. If a DragSourceListener already exists, this method throws a TooManyListenersException.

Parameters:
dsl - the DragSourceListener to add. Note that while null is not prohibited, it is not acceptable as a parameter.

Throws:
TooManyListenersException

dragDropEnd

public void dragDropEnd(DragSourceDropEvent dsde)
Calls dragDropEnd on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceDropEvent.

Parameters:
dsde - the DragSourceDropEvent

dragEnter

public void dragEnter(DragSourceDragEvent dsde)
Calls dragEnter on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceDragEvent.

Parameters:
dsde - the DragSourceDragEvent

dragExit

public void dragExit(DragSourceEvent dse)
Calls dragExit on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceEvent.

Parameters:
dse - the DragSourceEvent

dragMouseMoved

public void dragMouseMoved(DragSourceDragEvent dsde)
Calls dragMouseMoved on the DragSourceMotionListeners registered with the DragSource associated with this DragSourceContext, and them passes the specified DragSourceDragEvent.

Parameters:
dsde - the DragSourceDragEvent

dragOver

public void dragOver(DragSourceDragEvent dsde)
Calls dragOver on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceDragEvent.

Parameters:
dsde - the DragSourceDragEvent

dropActionChanged

public void dropActionChanged(DragSourceDragEvent dsde)
Calls dropActionChanged on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceDragEvent.

Parameters:
dsde - the DragSourceDragEvent

getComponent

public Component getComponent()
Returns the Component associated with this DragSourceContext.

Returns:
the Component that started the drag

getCursor

public Cursor getCursor()
Returns the current drag Cursor.

Returns:
the current drag Cursor

getDragSource

public DragSource getDragSource()
Returns the DragSource that instantiated this DragSourceContext.

Returns:
the DragSource that instantiated this DragSourceContext

getSourceActions

public int getSourceActions()
Returns a bitwise mask of DnDConstants that represent the set of drop actions supported by the drag source for the drag operation associated with this DragSourceContext.

Returns:
the drop actions supported by the drag source

getTransferable

public Transferable getTransferable()
Returns the Transferable associated with this DragSourceContext.

Returns:
the Transferable

getTrigger

public DragGestureEvent getTrigger()
Returns the DragGestureEvent that initially triggered the drag.

Returns:
the Event that triggered the drag

removeDragSourceListener

public synchronized void removeDragSourceListener(DragSourceListener dsl)
Removes the specified DragSourceListener from this DragSourceContext.

Parameters:
dsl - the DragSourceListener to remove; note that while null is not prohibited, it is not acceptable as a parameter

setCursor

public synchronized void setCursor(Cursor c)
Sets the cursor for this drag operation to the specified Cursor. If the specified Cursor is null, the default drag cursor behavior is activated for this drag operation, otherwise it is deactivated.

Parameters:
c - the Cursor to display, or null to activate the default drag cursor behavior

transferablesFlavorsChanged

public void transferablesFlavorsChanged()
Notifies the peer that the Transferable's DataFlavors have changed.


updateCurrentCursor

protected synchronized void updateCurrentCursor(int sourceAct,
                                                int targetAct,
                                                int status)
If the default drag cursor behavior is active, this method sets the default drag cursor for the specified actions supported by the drag source, the drop target action, and status, otherwise this method does nothing.

Parameters:
sourceAct - the actions supported by the drag source
targetAct - the drop target action
status - one of the fields DEFAULT, ENTER, OVER, CHANGED


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.