java.awt.dnd
Class DragSource

java.lang.Object
  |
  +--java.awt.dnd.DragSource
All Implemented Interfaces:
Serializable

public class DragSource
extends Object
implements Serializable

Unsafe:

See Also:
Serialized Form

Field Summary
static Cursor DefaultCopyDrop
          Enabled: The default Cursor to use with a copy operation indicating that a drop is currently allowed.
static Cursor DefaultCopyNoDrop
          Enabled: The default Cursor to use with a copy operation indicating that a drop is currently not allowed.
static Cursor DefaultLinkDrop
          Enabled: The default Cursor to use with a link operation indicating that a drop is currently allowed.
static Cursor DefaultLinkNoDrop
          Enabled: The default Cursor to use with a link operation indicating that a drop is currently not allowed.
static Cursor DefaultMoveDrop
          Enabled: The default Cursor to use with a move operation indicating that a drop is currently allowed.
static Cursor DefaultMoveNoDrop
          Enabled: The default Cursor to use with a move operation indicating that a drop is currently not allowed.
private static DragSource dflt
           
(package private) static String dragSourceListenerK
          Internal constants for serialization.
(package private) static String dragSourceMotionListenerK
           
private  FlavorMap flavorMap
           
private  DragSourceListener listener
           
private  DragSourceMotionListener motionListener
           
private static long serialVersionUID
           
 
Constructor Summary
DragSource()
          Enabled: Creates a new DragSource.
 
Method Summary
 void addDragSourceListener(DragSourceListener dsl)
          Suppressed: Adds the specified DragSourceListener to this DragSource to receive drag source events during drag operations intiated with this DragSource.
 void addDragSourceMotionListener(DragSourceMotionListener dsml)
          Suppressed: Adds the specified DragSourceMotionListener to this DragSource to receive drag motion events during drag operations intiated with this DragSource.
 DragGestureRecognizer createDefaultDragGestureRecognizer(Component c, int actions, DragGestureListener dgl)
          Enabled: 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.
 DragGestureRecognizer createDragGestureRecognizer(Class recognizerAbstractClass, Component c, int actions, DragGestureListener dgl)
          Enabled: 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 createDragSourceContext(java.awt.dnd.peer.DragSourceContextPeer dscp, DragGestureEvent dgl, Cursor dragCursor, Image dragImage, Point imageOffset, Transferable t, DragSourceListener dsl)
          Creates the DragSourceContext to handle this drag.
static DragSource getDefaultDragSource()
          Enabled: Gets the DragSource object associated with the underlying platform.
 DragSourceListener[] getDragSourceListeners()
          Suppressed: Gets all the DragSourceListeners registered with this DragSource.
 DragSourceMotionListener[] getDragSourceMotionListeners()
          Suppressed: Gets all of the DragSourceMotionListeners registered with this DragSource.
 FlavorMap getFlavorMap()
          Enabled: This method returns the FlavorMap for this DragSource.
 EventListener[] getListeners(Class listenerType)
          Suppressed: Gets all the objects currently registered as FooListeners upon this DragSource.
static boolean isDragImageSupported()
          Enabled: Reports whether or not drag Image support is available on the underlying platform.
private static Cursor load(String name)
           
(package private)  void processDragDropEnd(DragSourceDropEvent dsde)
          This method calls dragDropEnd on the DragSourceListeners registered with this DragSource, and passes them the specified DragSourceDropEvent.
(package private)  void processDragEnter(DragSourceDragEvent dsde)
          This method calls dragEnter on the DragSourceListeners registered with this DragSource, and passes them the specified DragSourceDragEvent.
(package private)  void processDragExit(DragSourceEvent dse)
          This method calls dragExit on the DragSourceListeners registered with this DragSource, and passes them the specified DragSourceEvent.
(package private)  void processDragMouseMoved(DragSourceDragEvent dsde)
          This method calls dragMouseMoved on the DragSourceMotionListeners registered with this DragSource, and passes them the specified DragSourceDragEvent.
(package private)  void processDragOver(DragSourceDragEvent dsde)
          This method calls dragOver on the DragSourceListeners registered with this DragSource, and passes them the specified DragSourceDragEvent.
(package private)  void processDropActionChanged(DragSourceDragEvent dsde)
          This method calls dropActionChanged on the DragSourceListeners registered with this DragSource, and passes them the specified DragSourceDragEvent.
private  void readObject(ObjectInputStream s)
          Deserializes this DragSource.
 void removeDragSourceListener(DragSourceListener dsl)
          Suppressed: Removes the specified DragSourceListener from this DragSource.
 void removeDragSourceMotionListener(DragSourceMotionListener dsml)
          Suppressed: Removes the specified DragSourceMotionListener from this DragSource.
 void startDrag(DragGestureEvent trigger, Cursor dragCursor, Image dragImage, Point dragOffset, Transferable transferable, DragSourceListener dsl)
          Enabled: 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.
 void startDrag(DragGestureEvent trigger, Cursor dragCursor, Image dragImage, Point imageOffset, Transferable transferable, DragSourceListener dsl, FlavorMap flavorMap)
          Enabled: 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.
 void startDrag(DragGestureEvent trigger, Cursor dragCursor, Transferable transferable, DragSourceListener dsl)
          Enabled: 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.
 void startDrag(DragGestureEvent trigger, Cursor dragCursor, Transferable transferable, DragSourceListener dsl, FlavorMap flavorMap)
          Enabled: 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.
private  void writeObject(ObjectOutputStream s)
          Serializes this DragSource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID

DefaultCopyDrop

public static final Cursor DefaultCopyDrop
Enabled: 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

DefaultMoveDrop

public static final Cursor DefaultMoveDrop
Enabled: 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

DefaultLinkDrop

public static final Cursor DefaultLinkDrop
Enabled: 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

DefaultCopyNoDrop

public static final Cursor DefaultCopyNoDrop
Enabled: 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

DefaultMoveNoDrop

public static final Cursor DefaultMoveNoDrop
Enabled: 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

DefaultLinkNoDrop

public static final Cursor DefaultLinkNoDrop
Enabled: 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

dflt

private static final DragSource dflt

dragSourceListenerK

static final String dragSourceListenerK
Internal constants for serialization.


dragSourceMotionListenerK

static final String dragSourceMotionListenerK

flavorMap

private transient FlavorMap flavorMap

listener

private transient DragSourceListener listener

motionListener

private transient DragSourceMotionListener motionListener
Constructor Detail

DragSource

public DragSource()
           throws HeadlessException
Enabled: Creates a new DragSource.

See Also:
java.awt.GraphicsEnvironment#isHeadless
Method Detail

load

private static Cursor load(String name)

getDefaultDragSource

public static DragSource getDefaultDragSource()
Enabled: Gets the DragSource object associated with the underlying platform.

Returns:
the platform DragSource
See Also:
java.awt.GraphicsEnvironment#isHeadless

isDragImageSupported

public static boolean isDragImageSupported()
Enabled: Reports whether or not drag Image support is available on the underlying platform.

Returns:
if the Drag Image support is available on this platform

startDrag

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

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
InvalidDnDOperationException

startDrag

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

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
InvalidDnDOperationException

startDrag

public void startDrag(DragGestureEvent trigger,
                      Cursor dragCursor,
                      Image dragImage,
                      Point dragOffset,
                      Transferable transferable,
                      DragSourceListener dsl)
               throws InvalidDnDOperationException
Enabled: 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 - the DragGestureEvent that initiated the drag
dragCursor - the initial Cursor or null for defaults
dragImage - the Image to drag or null
transferable - the subject data of the drag
dsl - the DragSourceListener

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
InvalidDnDOperationException

startDrag

public void startDrag(DragGestureEvent trigger,
                      Cursor dragCursor,
                      Transferable transferable,
                      DragSourceListener dsl)
               throws InvalidDnDOperationException
Enabled: 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 - the DragGestureEvent that initiated the drag
dragCursor - the initial Cursor or null for defaults
transferable - the subject data of the drag
dsl - the DragSourceListener

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
InvalidDnDOperationException

createDragSourceContext

protected DragSourceContext createDragSourceContext(java.awt.dnd.peer.DragSourceContextPeer dscp,
                                                    DragGestureEvent dgl,
                                                    Cursor dragCursor,
                                                    Image dragImage,
                                                    Point imageOffset,
                                                    Transferable t,
                                                    DragSourceListener dsl)
Creates the DragSourceContext to handle this drag.

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.

If dragCursor is null, the default drag cursors are used for this drag operation. NullPointerException is not thrown.

Parameters:
dscp - The DragSourceContextPeer for this drag
dgl - The DragGestureEvent that triggered the drag
dragCursor - The initial Cursor to display
dragImage - The Image to drag or null
imageOffset - The offset of the Image origin from the hotspot of the cursor at the instant of the trigger
t - The subject data of the drag
dsl - The DragSourceListener
Returns:
the DragSourceContext
Throws:
NullPointerException - if dscp is null
NullPointerException - if dgl is null
NullPointerException - if dragImage is not null and imageOffset is null
NullPointerException - if t is null
IllegalArgumentException - if the Component associated with the trigger event is null.
IllegalArgumentException - if the DragSource for the trigger event is null.
IllegalArgumentException - if the drag action for the trigger event is DnDConstants.ACTION_NONE.
IllegalArgumentException - if the source actions for the DragGestureRecognizer associated with the trigger event are equal to DnDConstants.ACTION_NONE.

getFlavorMap

public FlavorMap getFlavorMap()
Enabled: This method returns the FlavorMap for this DragSource.

Returns:
the FlavorMap for this DragSource

createDragGestureRecognizer

public DragGestureRecognizer createDragGestureRecognizer(Class recognizerAbstractClass,
                                                         Component c,
                                                         int actions,
                                                         DragGestureListener dgl)
Enabled: 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:
recognizerAbstractClass - the requested abstract type
actions - the permitted source drag actions
c - the Component target
dgl - the DragGestureListener to notify

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

createDefaultDragGestureRecognizer

public DragGestureRecognizer createDefaultDragGestureRecognizer(Component c,
                                                                int actions,
                                                                DragGestureListener dgl)
Enabled: 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 - the Component target for the recognizer
actions - the permitted source actions
dgl - the DragGestureListener to notify

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

addDragSourceListener

public void addDragSourceListener(DragSourceListener dsl)
Suppressed: Adds the specified DragSourceListener to this DragSource to receive drag source events during drag operations intiated with this DragSource. If a null listener is specified, no action is taken and no exception is thrown.

Parameters:
dsl - the DragSourceListener to add
Since:
1.4
See Also:
removeDragSourceListener(java.awt.dnd.DragSourceListener), getDragSourceListeners()

removeDragSourceListener

public void removeDragSourceListener(DragSourceListener dsl)
Suppressed: 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 - the DragSourceListener to remove
Since:
1.4
See Also:
addDragSourceListener(java.awt.dnd.DragSourceListener), getDragSourceListeners()

getDragSourceListeners

public DragSourceListener[] getDragSourceListeners()
Suppressed: Gets all the DragSourceListeners registered with this DragSource.

Returns:
all of this DragSource's DragSourceListeners or an empty array if no such listeners are currently registered
Since:
1.4
See Also:
addDragSourceListener(java.awt.dnd.DragSourceListener), removeDragSourceListener(java.awt.dnd.DragSourceListener)

addDragSourceMotionListener

public void addDragSourceMotionListener(DragSourceMotionListener dsml)
Suppressed: Adds the specified DragSourceMotionListener to this DragSource to receive drag motion events during drag operations intiated with this DragSource. If a null listener is specified, no action is taken and no exception is thrown.

Since:
1.4
See Also:
removeDragSourceMotionListener(java.awt.dnd.DragSourceMotionListener), getDragSourceMotionListeners()

removeDragSourceMotionListener

public void removeDragSourceMotionListener(DragSourceMotionListener dsml)
Suppressed: 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 - the DragSourceMotionListener to remove
Since:
1.4
See Also:
addDragSourceMotionListener(java.awt.dnd.DragSourceMotionListener), getDragSourceMotionListeners()

getDragSourceMotionListeners

public DragSourceMotionListener[] getDragSourceMotionListeners()
Suppressed: Gets all of the DragSourceMotionListeners registered with this DragSource.

Returns:
all of this DragSource's DragSourceMotionListeners or an empty array if no such listeners are currently registered
Since:
1.4
See Also:
addDragSourceMotionListener(java.awt.dnd.DragSourceMotionListener), removeDragSourceMotionListener(java.awt.dnd.DragSourceMotionListener)

getListeners

public EventListener[] getListeners(Class listenerType)
Suppressed: Gets all the objects currently registered as FooListeners upon this DragSource. FooListeners are registered using the addFooListener method.

Parameters:
listenerType - the type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener
Returns:
an array of all objects registered as FooListeners on this DragSource, or an empty array if no such listeners have been added
Since:
1.4
See Also:
getDragSourceListeners(), getDragSourceMotionListeners()

processDragEnter

void processDragEnter(DragSourceDragEvent dsde)
This method calls dragEnter on the DragSourceListeners registered with this DragSource, and passes them the specified DragSourceDragEvent.

Parameters:
dsde - the DragSourceDragEvent

processDragOver

void processDragOver(DragSourceDragEvent dsde)
This method calls dragOver on the DragSourceListeners registered with this DragSource, and passes them the specified DragSourceDragEvent.

Parameters:
dsde - the DragSourceDragEvent

processDropActionChanged

void processDropActionChanged(DragSourceDragEvent dsde)
This method calls dropActionChanged on the DragSourceListeners registered with this DragSource, and passes them the specified DragSourceDragEvent.

Parameters:
dsde - the DragSourceDragEvent

processDragExit

void processDragExit(DragSourceEvent dse)
This method calls dragExit on the DragSourceListeners registered with this DragSource, and passes them the specified DragSourceEvent.

Parameters:
dse - the DragSourceEvent

processDragDropEnd

void processDragDropEnd(DragSourceDropEvent dsde)
This method calls dragDropEnd on the DragSourceListeners registered with this DragSource, and passes them the specified DragSourceDropEvent.

Parameters:
dsde - the DragSourceEvent

processDragMouseMoved

void processDragMouseMoved(DragSourceDragEvent dsde)
This method calls dragMouseMoved on the DragSourceMotionListeners registered with this DragSource, and passes them the specified DragSourceDragEvent.

Parameters:
dsde - the DragSourceEvent

writeObject

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.

IOException
Since:
1.4

readObject

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.

ClassNotFoundException
IOException
Since:
1.4
See Also:
java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap


comments?