java.lang.Object
java.util.EventObject
java.awt.dnd.DragGestureEvent
- All Implemented Interfaces:
- Serializable
public class DragGestureEvent extends EventObject
A 
DragGestureEvent is passed
 to DragGestureListener's
 dragGestureRecognized() method
 when a particular DragGestureRecognizer detects that a
 platform dependent drag initiating gesture has occurred
 on the Component that it is tracking.
 The action field of any DragGestureEvent instance should take one of the following
 values:
 -  DnDConstants.ACTION_COPY
-  DnDConstants.ACTION_MOVE
-  DnDConstants.ACTION_LINK
- 
Field Summary
- 
Constructor SummaryConstructors Constructor Description DragGestureEvent(DragGestureRecognizer dgr, int act, Point ori, List<? extends InputEvent> evs)Constructs aDragGestureEventobject given by theDragGestureRecognizerinstance firing this event, anactparameter representing the user's preferred action, anoriparameter indicating the origin of the drag, and aListof events that comprise the gesture(evsparameter).
- 
Method SummaryModifier and Type Method Description ComponentgetComponent()Returns theComponentassociated with thisDragGestureEvent.intgetDragAction()Returns anintrepresenting the action selected by the user.PointgetDragOrigin()Returns aPointin the coordinates of theComponentover which the drag originated.DragSourcegetDragSource()Returns theDragSource.DragGestureRecognizergetSourceAsDragGestureRecognizer()Returns the source as aDragGestureRecognizer.InputEventgetTriggerEvent()Returns the initial event that triggered the gesture.Iterator<InputEvent>iterator()Returns anIteratorfor the events comprising the gesture.voidstartDrag(Cursor dragCursor, Transferable transferable)Starts the drag operation given theCursorfor this drag operation and theTransferablerepresenting the source data for this drag operation.voidstartDrag(Cursor dragCursor, Transferable transferable, DragSourceListener dsl)Starts the drag given the initialCursorto display, theTransferableobject, and theDragSourceListenerto use.voidstartDrag(Cursor dragCursor, Image dragImage, Point imageOffset, Transferable transferable, DragSourceListener dsl)Start the drag given the initialCursorto display, a dragImage, the offset of theImage, theTransferableobject, and theDragSourceListenerto use.Object[]toArray()Returns anObjectarray of the events comprising the drag gesture.Object[]toArray(Object[] array)Returns an array of the events comprising the drag gesture.
- 
Constructor Details- 
DragGestureEventpublic DragGestureEvent(DragGestureRecognizer dgr, int act, Point ori, List<? extends InputEvent> evs)Constructs aDragGestureEventobject given by theDragGestureRecognizerinstance firing this event, anactparameter representing the user's preferred action, anoriparameter indicating the origin of the drag, and aListof events that comprise the gesture(evsparameter).- Parameters:
- dgr- The- DragGestureRecognizerfiring this event
- act- The user's preferred action. For information on allowable values, see the class description for- DragGestureEvent
- ori- The origin of the drag
- evs- The- Listof events that comprise the gesture
- Throws:
- IllegalArgumentException- if any parameter equals- null
- IllegalArgumentException- if the act parameter does not comply with the values given in the class description for- DragGestureEvent
- See Also:
- DnDConstants
 
 
- 
- 
Method Details- 
getSourceAsDragGestureRecognizerReturns the source as aDragGestureRecognizer.- Returns:
- the source as a DragGestureRecognizer
 
- 
getComponentReturns theComponentassociated with thisDragGestureEvent.- Returns:
- the Component
 
- 
getDragSourceReturns theDragSource.- Returns:
- the DragSource
 
- 
getDragOriginReturns aPointin the coordinates of theComponentover which the drag originated.- Returns:
- the Point where the drag originated in Component coords.
 
- 
iteratorReturns anIteratorfor the events comprising the gesture.- Returns:
- an Iterator for the events comprising the gesture
 
- 
toArrayReturns anObjectarray of the events comprising the drag gesture.- Returns:
- an array of the events comprising the gesture
 
- 
toArrayReturns an array of the events comprising the drag gesture.- Parameters:
- array- the array of- EventObjectsub(types)
- Returns:
- an array of the events comprising the gesture
 
- 
getDragActionpublic int getDragAction()Returns anintrepresenting the action selected by the user.- Returns:
- the action selected by the user
 
- 
getTriggerEventReturns the initial event that triggered the gesture.- Returns:
- the first "triggering" event in the sequence of the gesture
 
- 
startDragpublic void startDrag(Cursor dragCursor, Transferable transferable) throws InvalidDnDOperationExceptionStarts the drag operation given theCursorfor this drag operation and theTransferablerepresenting the source data for this drag operation.
 If anull Cursoris specified no exception will be thrown and default drag cursors will be used instead.
 If anull Transferableis specifiedNullPointerExceptionwill be thrown.- Parameters:
- dragCursor- The initial- Cursorfor this drag operation or- nullfor the default cursor handling; see DragSourceContext for more details on the cursor handling mechanism during drag and drop
- transferable- The- Transferablerepresenting the source data for this drag operation.
- Throws:
- 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.
- NullPointerException- if the- Transferableis- null
- Since:
- 1.4
 
- 
startDragpublic void startDrag(Cursor dragCursor, Transferable transferable, DragSourceListener dsl) throws InvalidDnDOperationExceptionStarts the drag given the initialCursorto display, theTransferableobject, and theDragSourceListenerto use.- Parameters:
- dragCursor- The initial- Cursorfor this drag operation or- nullfor the default cursor handling; see DragSourceContext for more details on the cursor handling mechanism during drag and drop
- transferable- The source's Transferable
- dsl- The source's DragSourceListener
- Throws:
- 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.
 
- 
startDragpublic void startDrag(Cursor dragCursor, Image dragImage, Point imageOffset, Transferable transferable, DragSourceListener dsl) throws InvalidDnDOperationExceptionStart the drag given the initialCursorto display, a dragImage, the offset of theImage, theTransferableobject, and theDragSourceListenerto use.- Parameters:
- dragCursor- The initial- Cursorfor this drag operation or- nullfor the default cursor handling; see DragSourceContext for more details on the cursor handling mechanism during drag and drop
- dragImage- The source's dragImage
- imageOffset- The dragImage's offset
- transferable- The source's Transferable
- dsl- The source's DragSourceListener
- Throws:
- 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.
 
 
-