DragSource is the entity responsible
for the initiation of the Drag
and Drop operation, and may be used in a number of scenarios:
Component, or application specific
object associated with a Component
instance in the GUI. [implementation dependent]
DragSource is
obtained, a DragGestureRecognizer should
also be obtained to associate the DragSource
with a particular
Component.
The initial interpretation of the user's gesture,
and the subsequent starting of the drag operation
are the responsibility of the implementing
Component, which is usually
implemented by a DragGestureRecognizer.
When a drag gesture occurs, the
DragSource's
startDrag() method shall be
invoked in order to cause processing
of the user's navigational
gestures and delivery of Drag and Drop
protocol notifications. A
DragSource shall only
permit a single Drag and Drop operation to be
current at any one time, and shall
reject any further startDrag() requests
by throwing an IllegalDnDOperationException
until such time as the extant operation is complete.
The startDrag() method invokes the
createDragSourceContext() method to
instantiate an appropriate
DragSourceContext
and associate the DragSourceContextPeer
with that.
If the Drag and Drop System is
unable to initiate a drag operation for
some reason, the startDrag() method throws
a java.awt.dnd.InvalidDnDOperationException
to signal such a condition. Typically this
exception is thrown when the underlying platform
system is either not in a state to
initiate a drag, or the parameters specified are invalid.
Note that during the drag, the
set of operations exposed by the source
at the start of the drag operation may not change
until the operation is complete.
The operation(s) are constant for the
duration of the operation with respect to the
DragSource.
| Modifier and Type | Field and Description |
|---|---|
| public static final Cursor | DefaultCopyDrop
The default |
| public static final Cursor | DefaultCopyNoDrop
The default |
| public static final Cursor | DefaultLinkDrop
The default |
| public static final Cursor | DefaultLinkNoDrop
The default |
| public static final Cursor | DefaultMoveDrop
The default |
| public static final Cursor | DefaultMoveNoDrop
The default |
| private static final DragSource | |
| pack-priv static final String | dragSourceListenerK
Internal constants for serialization. |
| pack-priv static final String | |
| private transient FlavorMap | |
| private transient DragSourceListener | |
| private transient DragSourceMotionListener | |
| private static final long | serialVersionUID
Use serialVersionUID from JDK 1.4 for interoperability. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | addDragSourceListener(DragSourceListener
the dsl)DragSourceListener to addAdds the specified |
| public void | addDragSourceMotionListener(DragSourceMotionListener
the dsml)DragSourceMotionListener to addAdds the specified |
| public DragGestureRecognizer | Returns: the newDragGestureRecognizer or null
if the Toolkit.createDragGestureRecognizer method
has no implementation available for
the requested DragGestureRecognizer
subclass and returns nullthe c, int Component target for the recognizerthe permitted source actions actions, DragGestureListener the dgl)DragGestureListener to notifyCreates a new |
| public < the type of T extends DragGestureRecognizer> TDragGestureRecognizer to create | Returns: the newDragGestureRecognizer or null
if the Toolkit.createDragGestureRecognizer method
has no implementation available for
the requested DragGestureRecognizer
subclass and returns nullthe requested abstract type recognizerAbstractClass, Component the c, int Component targetthe permitted source drag actions actions, DragGestureListener the dgl)DragGestureListener to notifyCreates a new |
| protected DragSourceContext | Returns: theDragSourceContextThe dgl, Cursor DragGestureEvent that triggered the
dragThe initial dragCursor, Image Cursor for this drag operation
or null for the default cursor handling;
see DragSourceContext class
for more details on the cursor handling mechanism during drag and dropThe dragImage, Point Image to drag or nullThe offset of the imageOffset, Transferable Image origin from the
hotspot of the cursor at the instant of the triggerThe subject data of the drag t, DragSourceListener The dsl)DragSourceListenerCreates the |
| public static DragSource | Returns: the platform DragSourceGets the |
| public DragSourceListener[] | Returns: all of thisDragSource's
DragSourceListeners or an empty array if no
such listeners are currently registeredGets all the |
| public DragSourceMotionListener[] | Returns: all of thisDragSource's
DragSourceMotionListeners or an empty array if no
such listeners are currently registeredGets all of the |
| public static int | Returns: the drag gesture motion thresholdReturns the drag gesture motion threshold. |
| public FlavorMap | Returns: theFlavorMap for this DragSourceThis method returns the
|
| public < the type of listener objects T extends EventListener> T[] | Returns: an array of all objects registered asFooListeners on this
DragSource, or an empty array if no such listeners
have been addedthe type of listeners requested; this parameter
should specify an interface that descends from
listenerType)java.util.EventListenerGets all the objects currently registered as
|
| public static boolean | Returns: true if the Drag Image support is available on this
platform, otherwise falseReports whether or not drag |
| private static Cursor | |
| pack-priv void | processDragDropEnd(DragSourceDropEvent
the dsde)DragSourceEventThis method calls |
| pack-priv void | processDragEnter(DragSourceDragEvent
the dsde)DragSourceDragEventThis method calls |
| pack-priv void | processDragExit(DragSourceEvent
the dse)DragSourceEventThis method calls |
| pack-priv void | processDragMouseMoved(DragSourceDragEvent
the dsde)DragSourceEventThis method calls |
| pack-priv void | processDragOver(DragSourceDragEvent
the dsde)DragSourceDragEventThis method calls |
| pack-priv void | processDropActionChanged(DragSourceDragEvent
the dsde)DragSourceDragEventThis method calls |
| private void | |
| public void | removeDragSourceListener(DragSourceListener
the dsl)DragSourceListener to removeRemoves the specified |
| public void | removeDragSourceMotionListener(DragSourceMotionListener
the dsml)DragSourceMotionListener to removeRemoves the specified |
| public void | startDrag(DragGestureEvent
the trigger, Cursor DragGestureEvent that initiated the dragthe initial dragCursor, Image Cursor for this drag operation
or null for the default cursor handling;
see DragSourceContext
for more details on the cursor handling mechanism during drag and dropthe image to drag or dragImage, Point nullthe offset of the imageOffset, Transferable Image origin from the hotspot
of the Cursor at the instant of the triggerthe subject data of the drag transferable, DragSourceListener the dsl, FlavorMap DragSourceListenerthe flavorMap)FlavorMap to use, or nullStart a drag, given the |
| public void | startDrag(DragGestureEvent
the trigger, Cursor DragGestureEvent that
initiated the dragthe initial dragCursor, Transferable Cursor for this drag operation
or null for the default cursor handling;
see DragSourceContext
for more details on the cursor handling mechanism during drag and dropthe subject data of the drag transferable, DragSourceListener the dsl, FlavorMap DragSourceListenerthe flavorMap)FlavorMap to use or nullStart a drag, given the |
| public void | startDrag(DragGestureEvent
the trigger, Cursor DragGestureEvent that initiated the dragthe initial dragCursor, Image Cursor for this drag operation
or null for the default cursor handling;
see DragSourceContext
for more details on the cursor handling mechanism during drag and dropthe dragImage, Point Image to drag or nullthe offset of the dragOffset, Transferable Image origin from the hotspot
of the Cursor at the instant of the triggerthe subject data of the drag transferable, DragSourceListener the dsl)DragSourceListenerStart a drag, given the |
| public void | startDrag(DragGestureEvent
the trigger, Cursor DragGestureEvent that initiated the dragthe initial dragCursor, Transferable Cursor for this drag operation
or null for the default cursor handling;
see DragSourceContext class
for more details on the cursor handling mechanism during drag and dropthe subject data of the drag transferable, DragSourceListener the dsl)DragSourceListenerStart a drag, given the |
| private void |
| DefaultCopyDrop | back to summary |
|---|---|
| public static final Cursor DefaultCopyDrop The default | |
| DefaultCopyNoDrop | back to summary |
|---|---|
| public static final Cursor DefaultCopyNoDrop The default | |
| DefaultLinkDrop | back to summary |
|---|---|
| public static final Cursor DefaultLinkDrop The default | |
| DefaultLinkNoDrop | back to summary |
|---|---|
| public static final Cursor DefaultLinkNoDrop The default | |
| DefaultMoveDrop | back to summary |
|---|---|
| public static final Cursor DefaultMoveDrop The default | |
| DefaultMoveNoDrop | back to summary |
|---|---|
| public static final Cursor DefaultMoveNoDrop The default | |
| dflt | back to summary |
|---|---|
| private static final DragSource dflt | |
| dragSourceListenerK | back to summary |
|---|---|
| pack-priv static final String dragSourceListenerK Internal constants for serialization. | |
| dragSourceMotionListenerK | back to summary |
|---|---|
| pack-priv static final String dragSourceMotionListenerK | |
| flavorMap | back to summary |
|---|---|
| private transient FlavorMap flavorMap | |
| listener | back to summary |
|---|---|
| private transient DragSourceListener listener | |
| motionListener | back to summary |
|---|---|
| private transient DragSourceMotionListener motionListener | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Use serialVersionUID from JDK 1.4 for interoperability. | |
| DragSource | back to summary |
|---|---|
| public DragSource() throws HeadlessException Creates a new
| |
| addDragSourceListener | back to summary |
|---|---|
| public void addDragSourceListener(DragSourceListener dsl) Adds the specified
| |
| addDragSourceMotionListener | back to summary |
|---|---|
| public void addDragSourceMotionListener(DragSourceMotionListener dsml) Adds the specified
| |
| createDefaultDragGestureRecognizer | back to summary |
|---|---|
| public DragGestureRecognizer createDefaultDragGestureRecognizer(Component c, int actions, DragGestureListener dgl) Creates a new
| |
| createDragGestureRecognizer | back to summary |
|---|---|
| public <T extends DragGestureRecognizer> T createDragGestureRecognizer(Class<T> recognizerAbstractClass, Component c, int actions, DragGestureListener dgl) Creates a new
| |
| createDragSourceContext | back to summary |
|---|---|
| protected DragSourceContext createDragSourceContext(DragGestureEvent dgl, Cursor dragCursor, Image dragImage, Point imageOffset, Transferable t, DragSourceListener dsl) Creates the
To incorporate a new
If
If
| |
| getDefaultDragSource | back to summary |
|---|---|
| public static DragSource getDefaultDragSource() Gets the
| |
| getDragSourceListeners | back to summary |
|---|---|
| public DragSourceListener[] getDragSourceListeners() Gets all the
| |
| getDragSourceMotionListeners | back to summary |
|---|---|
| public DragSourceMotionListener[] getDragSourceMotionListeners() Gets all of the
| |
| getDragThreshold | back to summary |
|---|---|
| public static int getDragThreshold() Returns the drag gesture motion threshold. The drag gesture motion threshold
defines the recommended behavior for
If the system property
| |
| getFlavorMap | back to summary |
|---|---|
| public FlavorMap getFlavorMap() This method returns the
| |
| getListeners | back to summary |
|---|---|
| public <T extends EventListener> T[] getListeners(Class<T> listenerType) Gets all the objects currently registered as
| |
| isDragImageSupported | back to summary |
|---|---|
| public static boolean isDragImageSupported() Reports whether or not drag
| |
| load | back to summary |
|---|---|
| private static Cursor load(String name) | |
| processDragDropEnd | back to summary |
|---|---|
| pack-priv void processDragDropEnd(DragSourceDropEvent dsde) This method calls
| |
| processDragEnter | back to summary |
|---|---|
| pack-priv void processDragEnter(DragSourceDragEvent dsde) This method calls
| |
| processDragExit | back to summary |
|---|---|
| pack-priv void processDragExit(DragSourceEvent dse) This method calls
| |
| processDragMouseMoved | back to summary |
|---|---|
| pack-priv void processDragMouseMoved(DragSourceDragEvent dsde) This method calls
| |
| processDragOver | back to summary |
|---|---|
| pack-priv void processDragOver(DragSourceDragEvent dsde) This method calls
| |
| processDropActionChanged | back to summary |
|---|---|
| pack-priv void processDropActionChanged(DragSourceDragEvent dsde) This method calls
| |
| readObject | back to summary |
|---|---|
| private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException Deserializes this
| |
| removeDragSourceListener | back to summary |
|---|---|
| public void removeDragSourceListener(DragSourceListener dsl) Removes the specified
| |
| removeDragSourceMotionListener | back to summary |
|---|---|
| public void removeDragSourceMotionListener(DragSourceMotionListener dsml) Removes the specified
| |
| startDrag | back to summary |
|---|---|
| public void startDrag(DragGestureEvent trigger, Cursor dragCursor, Image dragImage, Point imageOffset, Transferable transferable, DragSourceListener dsl, FlavorMap flavorMap) throws InvalidDnDOperationException Start a drag, given the
| |
| startDrag | back to summary |
|---|---|
| public void startDrag(DragGestureEvent trigger, Cursor dragCursor, Transferable transferable, DragSourceListener dsl, FlavorMap flavorMap) throws InvalidDnDOperationException Start a drag, given the
| |
| startDrag | back to summary |
|---|---|
| public void startDrag(DragGestureEvent trigger, Cursor dragCursor, Image dragImage, Point dragOffset, Transferable transferable, DragSourceListener dsl) throws InvalidDnDOperationException Start a drag, given the
| |
| startDrag | back to summary |
|---|---|
| public void startDrag(DragGestureEvent trigger, Cursor dragCursor, Transferable transferable, DragSourceListener dsl) throws InvalidDnDOperationException Start a drag, given the
| |
| writeObject | back to summary |
|---|---|
| private void writeObject(ObjectOutputStream s) throws IOException Serializes this
| |