Serializable
public class DragGestureEvent extends EventObject
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
source
Constructor | Description |
---|---|
DragGestureEvent |
Constructs a DragGestureEvent object given by the DragGestureRecognizer instance firing this event, an act parameter representing the user's preferred action, an ori parameter indicating the origin of the drag, and a List of events that comprise the gesture(evs parameter). |
Modifier and Type | Method | Description |
---|---|---|
Component |
getComponent() |
Returns the Component associated with this DragGestureEvent . |
int |
getDragAction() |
Returns an int representing the action selected by the user. |
Point |
getDragOrigin() |
Returns a Point in the coordinates of the Component over which the drag originated. |
DragSource |
getDragSource() |
Returns the DragSource . |
DragGestureRecognizer |
getSourceAsDragGestureRecognizer() |
Returns the source as a DragGestureRecognizer . |
InputEvent |
getTriggerEvent() |
Returns the initial event that triggered the gesture. |
Iterator |
iterator() |
Returns an Iterator for the events comprising the gesture. |
void |
startDrag |
Starts the drag operation given the Cursor for this drag operation and the Transferable representing the source data for this drag operation. |
void |
startDrag |
Starts the drag given the initial Cursor to display, the Transferable object, and the DragSourceListener to use. |
void |
startDrag |
Start the drag given the initial Cursor to display, a drag Image , the offset of the Image , the Transferable object, and the DragSourceListener to use. |
Object[] |
toArray() |
Returns an Object array of the events comprising the drag gesture. |
Object[] |
toArray |
Returns an array of the events comprising the drag gesture. |
getSource, toString
public DragGestureEvent(DragGestureRecognizer dgr, int act, Point ori, List<? extends InputEvent> evs)
DragGestureEvent
object given by the DragGestureRecognizer
instance firing this event, an act
parameter representing the user's preferred action, an ori
parameter indicating the origin of the drag, and a List
of events that comprise the gesture(evs
parameter).dgr
- The DragGestureRecognizer
firing this eventact
- The user's preferred action. For information on allowable values, see the class description for DragGestureEvent
ori
- The origin of the dragevs
- The List
of events that comprise the gestureIllegalArgumentException
- if any parameter equals null
IllegalArgumentException
- if the act parameter does not comply with the values given in the class description for DragGestureEvent
public DragGestureRecognizer getSourceAsDragGestureRecognizer()
DragGestureRecognizer
.DragGestureRecognizer
public Component getComponent()
Component
associated with this DragGestureEvent
.public DragSource getDragSource()
DragSource
.DragSource
public Point getDragOrigin()
Point
in the coordinates of the Component
over which the drag originated.public Iterator<InputEvent> iterator()
Iterator
for the events comprising the gesture.public Object[] toArray()
Object
array of the events comprising the drag gesture.public Object[] toArray(Object[] array)
array
- the array of EventObject
sub(types)public int getDragAction()
int
representing the action selected by the user.public InputEvent getTriggerEvent()
public void startDrag(Cursor dragCursor, Transferable transferable) throws InvalidDnDOperationException
Cursor
for this drag operation and the Transferable
representing the source data for this drag operation. null Cursor
is specified no exception will be thrown and default drag cursors will be used instead. null Transferable
is specified NullPointerException
will be thrown.dragCursor
- 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 droptransferable
- The Transferable
representing the source data for this drag operation.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 Transferable
is null
public void startDrag(Cursor dragCursor, Transferable transferable, DragSourceListener dsl) throws InvalidDnDOperationException
Cursor
to display, the Transferable
object, and the DragSourceListener
to use.dragCursor
- 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 droptransferable
- The source's Transferabledsl
- The source's DragSourceListenerInvalidDnDOperationException
- 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.public void startDrag(Cursor dragCursor, Image dragImage, Point imageOffset, Transferable transferable, DragSourceListener dsl) throws InvalidDnDOperationException
Cursor
to display, a drag Image
, the offset of the Image
, the Transferable
object, and the DragSourceListener
to use.dragCursor
- 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 dropdragImage
- The source's dragImageimageOffset
- The dragImage's offsettransferable
- The source's Transferabledsl
- The source's DragSourceListenerInvalidDnDOperationException
- 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.
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/java/awt/dnd/DragGestureEvent.html