APIdia Launch Partner
Top Description Fields Constructors Methods
java.awt.dnd

public Class DragSource

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.awt.Component, .Cursor, .GraphicsEnvironment, .HeadlessException, .Image, .Point, .Toolkit, java.awt.datatransfer.FlavorMap, .SystemFlavorMap, .Transferable, java.io.IOException, .ObjectInputStream, .ObjectOutputStream, .Serial, .Serializable, java.util.EventListener, sun.awt.AWTAccessor, .AWTAccessor.DragSourceContextAccessor, sun.awt.dnd.SunDragSourceContextPeer

The DragSource is the entity responsible for the initiation of the Drag and Drop operation, and may be used in a number of scenarios: Once the 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.

Since
1.2

Field Summary

Modifier and TypeField and Description
public static final Cursor
DefaultCopyDrop

The default Cursor to use with a copy operation indicating that a drop is currently allowed.

public static final Cursor
DefaultCopyNoDrop

The default Cursor to use with a copy operation indicating that a drop is currently not allowed.

public static final Cursor
DefaultLinkDrop

The default Cursor to use with a link operation indicating that a drop is currently allowed.

public static final Cursor
DefaultLinkNoDrop

The default Cursor to use with a link operation indicating that a drop is currently not allowed.

public static final Cursor
DefaultMoveDrop

The default Cursor to use with a move operation indicating that a drop is currently allowed.

public static final Cursor
DefaultMoveNoDrop

The default Cursor to use with a move operation indicating that a drop is currently not allowed.

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.

Constructor Summary

AccessConstructor and Description
public
DragSource()

Creates a new DragSource.

Method Summary

Modifier and TypeMethod and Description
public void
addDragSourceListener(DragSourceListener
the DragSourceListener to add
dsl
)

Adds the specified DragSourceListener to this DragSource to receive drag source events during drag operations initiated with this DragSource.

public void
addDragSourceMotionListener(DragSourceMotionListener
the DragSourceMotionListener to add
dsml
)

Adds the specified DragSourceMotionListener to this DragSource to receive drag motion events during drag operations initiated with this DragSource.

public DragGestureRecognizer

Returns:

the new DragGestureRecognizer or null if the Toolkit.createDragGestureRecognizer method has no implementation available for the requested DragGestureRecognizer subclass and returns null
createDefaultDragGestureRecognizer
(Component
the Component target for the recognizer
c
,
int
the permitted source actions
actions
,
DragGestureListener
the DragGestureListener to notify
dgl
)

Creates a new DragGestureRecognizer that implements the default abstract subclass of DragGestureRecognizer for this DragSource, and sets the specified Component and DragGestureListener on the newly created object.

public <
the type of DragGestureRecognizer to create
T extends DragGestureRecognizer
>
T

Returns:

the new DragGestureRecognizer or null if the Toolkit.createDragGestureRecognizer method has no implementation available for the requested DragGestureRecognizer subclass and returns null
createDragGestureRecognizer
(Class<T>
the requested abstract type
recognizerAbstractClass
,
Component
the Component target
c
,
int
the permitted source drag actions
actions
,
DragGestureListener
the DragGestureListener to notify
dgl
)

Creates a new DragGestureRecognizer that implements the specified abstract subclass of DragGestureRecognizer, and sets the specified Component and DragGestureListener on the newly created object.

protected DragSourceContext

Returns:

the DragSourceContext
createDragSourceContext
(DragGestureEvent
The DragGestureEvent that triggered the drag
dgl
,
Cursor
The initial 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 drop
dragCursor
,
Image
The Image to drag or null
dragImage
,
Point
The offset of the Image origin from the hotspot of the cursor at the instant of the trigger
imageOffset
,
Transferable
The subject data of the drag
t
,
DragSourceListener
The DragSourceListener
dsl
)

Creates the DragSourceContext to handle the current drag operation.

public static DragSource

Returns:

the platform DragSource
getDefaultDragSource
()

Gets the DragSource object associated with the underlying platform.

public DragSourceListener[]

Returns:

all of this DragSource's DragSourceListeners or an empty array if no such listeners are currently registered
getDragSourceListeners
()

Gets all the DragSourceListeners registered with this DragSource.

public DragSourceMotionListener[]

Returns:

all of this DragSource's DragSourceMotionListeners or an empty array if no such listeners are currently registered
getDragSourceMotionListeners
()

Gets all of the DragSourceMotionListeners registered with this DragSource.

public static int

Returns:

the drag gesture motion threshold
getDragThreshold
()

Returns the drag gesture motion threshold.

public FlavorMap

Returns:

the FlavorMap for this DragSource
getFlavorMap
()

This method returns the FlavorMap for this DragSource.

public <
the type of listener objects
T extends EventListener
>
T[]

Returns:

an array of all objects registered as FooListeners on this DragSource, or an empty array if no such listeners have been added
getListeners
(Class<T>
the type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener
listenerType
)

Gets all the objects currently registered as FooListeners upon this DragSource.

public static boolean

Returns:

true if the Drag Image support is available on this platform, otherwise false
isDragImageSupported
()

Reports whether or not drag Image support is available on the underlying platform.

private static Cursor
load(String name)

pack-priv void
processDragDropEnd(DragSourceDropEvent
the DragSourceEvent
dsde
)

This method calls dragDropEnd on the DragSourceListeners registered with this DragSource, and passes them the specified DragSourceDropEvent.

pack-priv void
processDragEnter(DragSourceDragEvent
the DragSourceDragEvent
dsde
)

This method calls dragEnter on the DragSourceListeners registered with this DragSource, and passes them the specified DragSourceDragEvent.

pack-priv void
processDragExit(DragSourceEvent
the DragSourceEvent
dse
)

This method calls dragExit on the DragSourceListeners registered with this DragSource, and passes them the specified DragSourceEvent.

pack-priv void
processDragMouseMoved(DragSourceDragEvent
the DragSourceEvent
dsde
)

This method calls dragMouseMoved on the DragSourceMotionListeners registered with this DragSource, and passes them the specified DragSourceDragEvent.

pack-priv void
processDragOver(DragSourceDragEvent
the DragSourceDragEvent
dsde
)

This method calls dragOver on the DragSourceListeners registered with this DragSource, and passes them the specified DragSourceDragEvent.

pack-priv void
processDropActionChanged(DragSourceDragEvent
the DragSourceDragEvent
dsde
)

This method calls dropActionChanged on the DragSourceListeners registered with this DragSource, and passes them the specified DragSourceDragEvent.

private void
readObject(ObjectInputStream
the ObjectInputStream to read
s
)

Deserializes this DragSource.

public void
removeDragSourceListener(DragSourceListener
the DragSourceListener to remove
dsl
)

Removes the specified DragSourceListener from this DragSource.

public void
removeDragSourceMotionListener(DragSourceMotionListener
the DragSourceMotionListener to remove
dsml
)

Removes the specified DragSourceMotionListener from this DragSource.

public void
startDrag(DragGestureEvent
the DragGestureEvent that initiated the drag
trigger
,
Cursor
the initial 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 drop
dragCursor
,
Image
the image to drag or null
dragImage
,
Point
the offset of the Image origin from the hotspot of the Cursor at the instant of the trigger
imageOffset
,
Transferable
the subject data of the drag
transferable
,
DragSourceListener
the DragSourceListener
dsl
,
FlavorMap
the FlavorMap to use, or null
flavorMap
)

Start a drag, given the DragGestureEvent that initiated the drag, the initial Cursor to use, the Image to drag, the offset of the Image origin from the hotspot of the Cursor at the instant of the trigger, the Transferable subject data of the drag, the DragSourceListener, and the FlavorMap.

public void
startDrag(DragGestureEvent
the DragGestureEvent that initiated the drag
trigger
,
Cursor
the initial 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 drop
dragCursor
,
Transferable
the subject data of the drag
transferable
,
DragSourceListener
the DragSourceListener
dsl
,
FlavorMap
the FlavorMap to use or null
flavorMap
)

Start a drag, given the DragGestureEvent that initiated the drag, the initial Cursor to use, the Transferable subject data of the drag, the DragSourceListener, and the FlavorMap.

public void
startDrag(DragGestureEvent
the DragGestureEvent that initiated the drag
trigger
,
Cursor
the initial 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 drop
dragCursor
,
Image
the Image to drag or null
dragImage
,
Point
the offset of the Image origin from the hotspot of the Cursor at the instant of the trigger
dragOffset
,
Transferable
the subject data of the drag
transferable
,
DragSourceListener
the DragSourceListener
dsl
)

Start a drag, given the DragGestureEvent that initiated the drag, the initial Cursor to use, the Image to drag, the offset of the Image origin from the hotspot of the Cursor at the instant of the trigger, the subject data of the drag, and the DragSourceListener.

public void
startDrag(DragGestureEvent
the DragGestureEvent that initiated the drag
trigger
,
Cursor
the initial 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 drop
dragCursor
,
Transferable
the subject data of the drag
transferable
,
DragSourceListener
the DragSourceListener
dsl
)

Start a drag, given the DragGestureEvent that initiated the drag, the initial Cursor to use, the Transferable subject data of the drag, and the DragSourceListener.

private void
writeObject(ObjectOutputStream
the ObjectOutputStream to write
s
)

Serializes this DragSource.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DefaultCopyDropback to summary
public static final Cursor DefaultCopyDrop

The default Cursor to use with a copy operation indicating that a drop is currently allowed. null if GraphicsEnvironment.isHeadless() returns true.

See Also
java.awt.GraphicsEnvironment#isHeadless
DefaultCopyNoDropback to summary
public static final Cursor DefaultCopyNoDrop

The default Cursor to use with a copy operation indicating that a drop is currently not allowed. null if GraphicsEnvironment.isHeadless() returns true.

See Also
java.awt.GraphicsEnvironment#isHeadless
DefaultLinkDropback to summary
public static final Cursor DefaultLinkDrop

The default Cursor to use with a link operation indicating that a drop is currently allowed. null if GraphicsEnvironment.isHeadless() returns true.

See Also
java.awt.GraphicsEnvironment#isHeadless
DefaultLinkNoDropback to summary
public static final Cursor DefaultLinkNoDrop

The default Cursor to use with a link operation indicating that a drop is currently not allowed. null if GraphicsEnvironment.isHeadless() returns true.

See Also
java.awt.GraphicsEnvironment#isHeadless
DefaultMoveDropback to summary
public static final Cursor DefaultMoveDrop

The default Cursor to use with a move operation indicating that a drop is currently allowed. null if GraphicsEnvironment.isHeadless() returns true.

See Also
java.awt.GraphicsEnvironment#isHeadless
DefaultMoveNoDropback to summary
public static final Cursor DefaultMoveNoDrop

The default Cursor to use with a move operation indicating that a drop is currently not allowed. null if GraphicsEnvironment.isHeadless() returns true.

See Also
java.awt.GraphicsEnvironment#isHeadless
dfltback to summary
private static final DragSource dflt
dragSourceListenerKback to summary
pack-priv static final String dragSourceListenerK

Internal constants for serialization.

dragSourceMotionListenerKback to summary
pack-priv static final String dragSourceMotionListenerK
flavorMapback to summary
private transient FlavorMap flavorMap
listenerback to summary
private transient DragSourceListener listener
motionListenerback to summary
private transient DragSourceMotionListener motionListener
serialVersionUIDback to summary
private static final long serialVersionUID

Use serialVersionUID from JDK 1.4 for interoperability.

Annotations
@Serial

Constructor Detail

DragSourceback to summary
public DragSource() throws HeadlessException

Creates a new DragSource.

Exceptions
HeadlessException:
if GraphicsEnvironment.isHeadless() returns true
See Also
java.awt.GraphicsEnvironment#isHeadless

Method Detail

addDragSourceListenerback to summary
public void addDragSourceListener(DragSourceListener dsl)

Adds the specified DragSourceListener to this DragSource to receive drag source events during drag operations initiated with this DragSource. If a null listener is specified, no action is taken and no exception is thrown.

Parameters
dsl:DragSourceListener

the DragSourceListener to add

Since
1.4
See Also
removeDragSourceListener, getDragSourceListeners
addDragSourceMotionListenerback to summary
public void addDragSourceMotionListener(DragSourceMotionListener dsml)

Adds the specified DragSourceMotionListener to this DragSource to receive drag motion events during drag operations initiated with this DragSource. If a null listener is specified, no action is taken and no exception is thrown.

Parameters
dsml:DragSourceMotionListener

the DragSourceMotionListener to add

Since
1.4
See Also
removeDragSourceMotionListener, getDragSourceMotionListeners
createDefaultDragGestureRecognizerback to summary
public DragGestureRecognizer createDefaultDragGestureRecognizer(Component c, int actions, DragGestureListener dgl)

Creates a new DragGestureRecognizer that implements the default abstract subclass of DragGestureRecognizer for this DragSource, and sets the specified Component and DragGestureListener on the newly created object. For this DragSource the default is MouseDragGestureRecognizer.

Parameters
c:Component

the Component target for the recognizer

actions:int

the permitted source actions

dgl:DragGestureListener

the DragGestureListener to notify

Returns:DragGestureRecognizer

the new DragGestureRecognizer or null if the Toolkit.createDragGestureRecognizer method has no implementation available for the requested DragGestureRecognizer subclass and returns null

createDragGestureRecognizerback to summary
public <T extends DragGestureRecognizer> T createDragGestureRecognizer(Class<T> recognizerAbstractClass, Component c, int actions, DragGestureListener dgl)

Creates a new DragGestureRecognizer that implements the specified abstract subclass of DragGestureRecognizer, and sets the specified Component and DragGestureListener on the newly created object.

Parameters
<T>
the type of DragGestureRecognizer to create
recognizerAbstractClass:Class<T>

the requested abstract type

c:Component

the Component target

actions:int

the permitted source drag actions

dgl:DragGestureListener

the DragGestureListener to notify

Returns:T

the new DragGestureRecognizer or null if the Toolkit.createDragGestureRecognizer method has no implementation available for the requested DragGestureRecognizer subclass and returns null

createDragSourceContextback to summary
protected DragSourceContext createDragSourceContext(DragGestureEvent dgl, Cursor dragCursor, Image dragImage, Point imageOffset, Transferable t, DragSourceListener dsl)

Creates the DragSourceContext to handle the current drag operation.

To incorporate a new DragSourceContext subclass, subclass DragSource and override this method.

If dragImage is null, no image is used to represent the drag over feedback for this drag operation, but NullPointerException is not thrown.

If dsl is null, no drag source listener is registered with the created DragSourceContext, but NullPointerException is not thrown.

Parameters
dgl:DragGestureEvent

The DragGestureEvent that triggered the drag

dragCursor:Cursor

The initial 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 drop

dragImage:Image

The Image to drag or null

imageOffset:Point

The offset of the Image origin from the hotspot of the cursor at the instant of the trigger

t:Transferable

The subject data of the drag

dsl:DragSourceListener

The DragSourceListener

Returns:DragSourceContext

the DragSourceContext

Exceptions
NullPointerException:
  • if dscp is null
  • if dgl is null
  • if dragImage is not null and imageOffset is null
  • if t is null
IllegalArgumentException:
  • if the Component associated with the trigger event is null.
  • if the DragSource for the trigger event is null.
  • if the drag action for the trigger event is DnDConstants.ACTION_NONE.
  • if the source actions for the DragGestureRecognizer associated with the trigger event are equal to DnDConstants.ACTION_NONE.
getDefaultDragSourceback to summary
public static DragSource getDefaultDragSource()

Gets the DragSource object associated with the underlying platform.

Returns:DragSource

the platform DragSource

Exceptions
HeadlessException:
if GraphicsEnvironment.isHeadless() returns true
See Also
java.awt.GraphicsEnvironment#isHeadless
getDragSourceListenersback to summary
public DragSourceListener[] getDragSourceListeners()

Gets all the DragSourceListeners registered with this DragSource.

Returns:DragSourceListener[]

all of this DragSource's DragSourceListeners or an empty array if no such listeners are currently registered

Since
1.4
See Also
addDragSourceListener, removeDragSourceListener
getDragSourceMotionListenersback to summary
public DragSourceMotionListener[] getDragSourceMotionListeners()

Gets all of the DragSourceMotionListeners registered with this DragSource.

Returns:DragSourceMotionListener[]

all of this DragSource's DragSourceMotionListeners or an empty array if no such listeners are currently registered

Since
1.4
See Also
addDragSourceMotionListener, removeDragSourceMotionListener
getDragThresholdback to summary
public static int getDragThreshold()

Returns the drag gesture motion threshold. The drag gesture motion threshold defines the recommended behavior for MouseDragGestureRecognizers.

If the system property awt.dnd.drag.threshold is set to a positive integer, this method returns the value of the system property; otherwise if a pertinent desktop property is available and supported by the implementation of the Java platform, this method returns the value of that property; otherwise this method returns some default value. The pertinent desktop property can be queried using java.awt.Toolkit.getDesktopProperty("DnD.gestureMotionThreshold").

Returns:int

the drag gesture motion threshold

Since
1.5
See Also
MouseDragGestureRecognizer
getFlavorMapback to summary
public FlavorMap getFlavorMap()

This method returns the FlavorMap for this DragSource.

Returns:FlavorMap

the FlavorMap for this DragSource

getListenersback to summary
public <T extends EventListener> T[] getListeners(Class<T> listenerType)

Gets all the objects currently registered as FooListeners upon this DragSource. FooListeners are registered using the addFooListener method.

Parameters
<T>
the type of listener objects
listenerType:Class<T>

the type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener

Returns:T[]

an array of all objects registered as FooListeners on this DragSource, or an empty array if no such listeners have been added

Exceptions
ClassCastException:
if listenerType doesn't specify a class or interface that implements java.util.EventListener
Since
1.4
See Also
getDragSourceListeners, getDragSourceMotionListeners
isDragImageSupportedback to summary
public static boolean isDragImageSupported()

Reports whether or not drag Image support is available on the underlying platform.

Returns:boolean

true if the Drag Image support is available on this platform, otherwise false

loadback to summary
private static Cursor load(String name)
processDragDropEndback to summary
pack-priv void processDragDropEnd(DragSourceDropEvent dsde)

This method calls dragDropEnd on the DragSourceListeners registered with this DragSource, and passes them the specified DragSourceDropEvent.

Parameters
dsde:DragSourceDropEvent

the DragSourceEvent

processDragEnterback to summary
pack-priv void processDragEnter(DragSourceDragEvent dsde)

This method calls dragEnter on the DragSourceListeners registered with this DragSource, and passes them the specified DragSourceDragEvent.

Parameters
dsde:DragSourceDragEvent

the DragSourceDragEvent

processDragExitback to summary
pack-priv void processDragExit(DragSourceEvent dse)

This method calls dragExit on the DragSourceListeners registered with this DragSource, and passes them the specified DragSourceEvent.

Parameters
dse:DragSourceEvent

the DragSourceEvent

processDragMouseMovedback to summary
pack-priv void processDragMouseMoved(DragSourceDragEvent dsde)

This method calls dragMouseMoved on the DragSourceMotionListeners registered with this DragSource, and passes them the specified DragSourceDragEvent.

Parameters
dsde:DragSourceDragEvent

the DragSourceEvent

processDragOverback to summary
pack-priv void processDragOver(DragSourceDragEvent dsde)

This method calls dragOver on the DragSourceListeners registered with this DragSource, and passes them the specified DragSourceDragEvent.

Parameters
dsde:DragSourceDragEvent

the DragSourceDragEvent

processDropActionChangedback to summary
pack-priv void processDropActionChanged(DragSourceDragEvent dsde)

This method calls dropActionChanged on the DragSourceListeners registered with this DragSource, and passes them the specified DragSourceDragEvent.

Parameters
dsde:DragSourceDragEvent

the DragSourceDragEvent

readObjectback to summary
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException

Deserializes this DragSource. This method first performs default deserialization. Next, this object's FlavorMap is deserialized by using the next object in the stream. If the resulting FlavorMap is null, this object's FlavorMap is set to the default FlavorMap for this thread's ClassLoader. Next, this object's listeners are deserialized by reading a null-terminated sequence of 0 or more key/value pairs from the stream:

  • If a key object is a String equal to dragSourceListenerK, a DragSourceListener is deserialized using the corresponding value object and added to this DragSource.
  • If a key object is a String equal to dragSourceMotionListenerK, a DragSourceMotionListener is deserialized using the corresponding value object and added to this DragSource.
  • Otherwise, the key/value pair is skipped.
Parameters
s:ObjectInputStream

the ObjectInputStream to read

Annotations
@Serial
Exceptions
ClassNotFoundException:
if the class of a serialized object could not be found
IOException:
if an I/O error occurs
Since
1.4
See Also
java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap
removeDragSourceListenerback to summary
public void removeDragSourceListener(DragSourceListener dsl)

Removes the specified DragSourceListener from this DragSource. If a null listener is specified, no action is taken and no exception is thrown. If the listener specified by the argument was not previously added to this DragSource, no action is taken and no exception is thrown.

Parameters
dsl:DragSourceListener

the DragSourceListener to remove

Since
1.4
See Also
addDragSourceListener, getDragSourceListeners
removeDragSourceMotionListenerback to summary
public void removeDragSourceMotionListener(DragSourceMotionListener dsml)

Removes the specified DragSourceMotionListener from this DragSource. If a null listener is specified, no action is taken and no exception is thrown. If the listener specified by the argument was not previously added to this DragSource, no action is taken and no exception is thrown.

Parameters
dsml:DragSourceMotionListener

the DragSourceMotionListener to remove

Since
1.4
See Also
addDragSourceMotionListener, getDragSourceMotionListeners
startDragback 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 DragGestureEvent that initiated the drag, the initial Cursor to use, the Image to drag, the offset of the Image origin from the hotspot of the Cursor at the instant of the trigger, the Transferable subject data of the drag, the DragSourceListener, and the FlavorMap.

Parameters
trigger:DragGestureEvent

the DragGestureEvent that initiated the drag

dragCursor:Cursor

the initial 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 drop

dragImage:Image

the image to drag or null

imageOffset:Point

the offset of the Image origin from the hotspot of the Cursor at the instant of the trigger

transferable:Transferable

the subject data of the drag

dsl:DragSourceListener

the DragSourceListener

flavorMap:FlavorMap

the FlavorMap to use, or null

Exceptions
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
startDragback to summary
public void startDrag(DragGestureEvent trigger, Cursor dragCursor, Transferable transferable, DragSourceListener dsl, FlavorMap flavorMap) throws InvalidDnDOperationException

Start a drag, given the DragGestureEvent that initiated the drag, the initial Cursor to use, the Transferable subject data of the drag, the DragSourceListener, and the FlavorMap.

Parameters
trigger:DragGestureEvent

the DragGestureEvent that initiated the drag

dragCursor:Cursor

the initial 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 drop

transferable:Transferable

the subject data of the drag

dsl:DragSourceListener

the DragSourceListener

flavorMap:FlavorMap

the FlavorMap to use or null

Exceptions
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
startDragback to summary
public void startDrag(DragGestureEvent trigger, Cursor dragCursor, Image dragImage, Point dragOffset, Transferable transferable, DragSourceListener dsl) throws InvalidDnDOperationException

Start a drag, given the DragGestureEvent that initiated the drag, the initial Cursor to use, the Image to drag, the offset of the Image origin from the hotspot of the Cursor at the instant of the trigger, the subject data of the drag, and the DragSourceListener.

Parameters
trigger:DragGestureEvent

the DragGestureEvent that initiated the drag

dragCursor:Cursor

the initial 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 drop

dragImage:Image

the Image to drag or null

dragOffset:Point

the offset of the Image origin from the hotspot of the Cursor at the instant of the trigger

transferable:Transferable

the subject data of the drag

dsl:DragSourceListener

the DragSourceListener

Exceptions
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
startDragback to summary
public void startDrag(DragGestureEvent trigger, Cursor dragCursor, Transferable transferable, DragSourceListener dsl) throws InvalidDnDOperationException

Start a drag, given the DragGestureEvent that initiated the drag, the initial Cursor to use, the Transferable subject data of the drag, and the DragSourceListener.

Parameters
trigger:DragGestureEvent

the DragGestureEvent that initiated the drag

dragCursor:Cursor

the initial 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 drop

transferable:Transferable

the subject data of the drag

dsl:DragSourceListener

the DragSourceListener

Exceptions
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
writeObjectback to summary
private void writeObject(ObjectOutputStream s) throws IOException

Serializes this DragSource. This method first performs default serialization. Next, it writes out this object's FlavorMap if and only if it can be serialized. If not, null is written instead. Next, it writes out Serializable listeners registered with this object. Listeners are written in a null-terminated sequence of 0 or more pairs. The pair consists of a String and an Object; the String indicates the type of the Object and is one of the following:

  • dragSourceListenerK indicating a DragSourceListener object;
  • dragSourceMotionListenerK indicating a DragSourceMotionListener object.
Parameters
s:ObjectOutputStream

the ObjectOutputStream to write

Annotations
@Serial
Exceptions
IOException:
if an I/O error occurs
Since
1.4
Serial data
Either a FlavorMap instance, or null, followed by a null-terminated sequence of 0 or more pairs; the pair consists of a String and an Object; the String indicates the type of the Object and is one of the following:
  • dragSourceListenerK indicating a DragSourceListener object;
  • dragSourceMotionListenerK indicating a DragSourceMotionListener object.
.