Spec-Zone.ru › OpenJDK 27

Class DragGestureEvent

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
Assigning the value different from listed above will cause an unspecified behavior.
See Also:
  • DragGestureRecognizer
  • DragGestureListener
  • DragSource
  • DnDConstants
  • Serialized Form

Field Summary

Fields declared in class EventObject

source
Modifier and Type Field Description
protected Object source
The object on which the Event initially occurred.

Constructor Summary

Constructor Description
DragGestureEvent(DragGestureRecognizer dgr, int act, Point ori, List<? extends InputEvent> evs)
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).

Method Summary

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<InputEvent> iterator()
Returns an Iterator for the events comprising the gesture.
void startDrag(Cursor dragCursor, Transferable transferable)
Starts the drag operation given the Cursor for this drag operation and the Transferable representing the source data for this drag operation.
void startDrag(Cursor dragCursor, Transferable transferable, DragSourceListener dsl)
Starts the drag given the initial Cursor to display, the Transferable object, and the DragSourceListener to use.
void startDrag(Cursor dragCursor, Image dragImage, Point imageOffset, Transferable transferable, DragSourceListener dsl)
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(Object[] array)
Returns an array of the events comprising the drag gesture.

Methods declared in class EventObject

getSource, toString
Modifier and Type Method Description
Object getSource()
The object on which the Event initially occurred.
String toString()
Returns a String representation of this EventObject.

Methods declared in class Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Modifier and Type Method Description
protected Object clone()
Creates and returns a copy of this object.
boolean equals(Object obj)
Indicates whether some other object is "equal to" this one.
protected void finalize()
Deprecated, for removal: This API element is subject to removal in a future version.
Finalization is deprecated and subject to removal in a future release.
final Class<?> getClass()
Returns the runtime class of this Object.
int hashCode()
Returns a hash code value for this object.
final void notify()
Wakes up a single thread that is waiting on this object's monitor.
final void notifyAll()
Wakes up all threads that are waiting on this object's monitor.
final void wait()
Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
final void wait(long timeoutMillis)
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
final void wait(long timeoutMillis, int nanos)
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

Constructor Details

DragGestureEvent

public DragGestureEvent(DragGestureRecognizer dgr, int act, Point ori, List<? extends InputEvent> evs)
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).
Parameters:
dgr - The DragGestureRecognizer firing 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 List of 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

getSourceAsDragGestureRecognizer

public DragGestureRecognizer getSourceAsDragGestureRecognizer()
Returns the source as a DragGestureRecognizer.
Returns:
the source as a DragGestureRecognizer

getComponent

public Component getComponent()
Returns the Component associated with this DragGestureEvent.
Returns:
the Component

getDragSource

public DragSource getDragSource()
Returns the DragSource.
Returns:
the DragSource

getDragOrigin

public Point getDragOrigin()
Returns a Point in the coordinates of the Component over which the drag originated.
Returns:
the Point where the drag originated in Component coords.

iterator

public Iterator<InputEvent> iterator()
Returns an Iterator for the events comprising the gesture.
Returns:
an Iterator for the events comprising the gesture

toArray

public Object[] toArray()
Returns an Object array of the events comprising the drag gesture.
Returns:
an array of the events comprising the gesture

toArray

public Object[] toArray(Object[] array)
Returns an array of the events comprising the drag gesture.
Parameters:
array - the array of EventObject sub(types)
Returns:
an array of the events comprising the gesture

getDragAction

public int getDragAction()
Returns an int representing the action selected by the user.
Returns:
the action selected by the user

getTriggerEvent

public InputEvent getTriggerEvent()
Returns the initial event that triggered the gesture.
Returns:
the first "triggering" event in the sequence of the gesture

startDrag

public void startDrag(Cursor dragCursor, Transferable transferable) throws InvalidDnDOperationException
Starts the drag operation given the Cursor for this drag operation and the Transferable representing the source data for this drag operation.
If a null Cursor is specified no exception will be thrown and default drag cursors will be used instead.
If a null Transferable is specified NullPointerException will be thrown.
Parameters:
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 drop
transferable - The Transferable representing 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 Transferable is null
Since:
1.4

startDrag

public void startDrag(Cursor dragCursor, Transferable transferable, DragSourceListener dsl) throws InvalidDnDOperationException
Starts the drag given the initial Cursor to display, the Transferable object, and the DragSourceListener to use.
Parameters:
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 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.

startDrag

public void startDrag(Cursor dragCursor, Image dragImage, Point imageOffset, Transferable transferable, DragSourceListener dsl) throws InvalidDnDOperationException
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.
Parameters:
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 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.

Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples. Other versions.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2026, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.

© 1993, 2025, 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.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API