SerializableMouseDragGestureRecognizerpublic abstract class DragGestureRecognizer extends Object implements Serializable
DragGestureRecognizer is an abstract base class for the specification of a platform-dependent listener that can be associated with a particular Component in order to identify platform-dependent drag initiating gestures.  The appropriate DragGestureRecognizer subclass instance is obtained from the DragSource associated with a particular Component, or from the Toolkit object via its createDragGestureRecognizer() method. 
 Once the DragGestureRecognizer is associated with a particular Component it will register the appropriate listener interfaces on that Component in order to track the input events delivered to the Component. 
 Once the DragGestureRecognizer identifies a sequence of events on the Component as a drag initiating gesture, it will notify its unicast DragGestureListener by invoking its gestureRecognized() method. 
 When a concrete DragGestureRecognizer instance detects a drag initiating gesture on the Component it is associated with, it fires a DragGestureEvent to the DragGestureListener registered on its unicast event source for DragGestureListener events. This DragGestureListener is responsible for causing the associated DragSource to start the Drag and Drop operation (if appropriate).
| Modifier and Type | Field | Description | 
|---|---|---|
| protected Component | component | The  Componentassociated with thisDragGestureRecognizer. | 
| protected DragGestureListener | dragGestureListener | The  DragGestureListenerassociated with thisDragGestureRecognizer. | 
| protected DragSource | dragSource | The  DragSourceassociated with thisDragGestureRecognizer. | 
| protected ArrayList | events | The list of events (in order) that the  DragGestureRecognizer"recognized" as a "gesture" that triggers a drag. | 
| protected int | sourceActions | An  intrepresenting the type(s) of action(s) used in this Drag and Drop operation. | 
| Modifier | Constructor | Description | 
|---|---|---|
| protected  | Construct a new  DragGestureRecognizergiven theDragSourceto be used in this Drag and Drop operation. | |
| protected  | Construct a new  DragGestureRecognizergiven theDragSourceto be used in this Drag and Drop operation, and theComponentthisDragGestureRecognizershould "observe" for drag initiating gestures. | |
| protected  | Construct a new  DragGestureRecognizergiven theDragSourceto be used in this Drag and Drop operation, theComponentthisDragGestureRecognizershould "observe" for drag initiating gestures, and the action(s) supported for this Drag and Drop operation. | |
| protected  | Construct a new  DragGestureRecognizergiven theDragSourceto be used in this Drag and Drop operation, theComponentthisDragGestureRecognizershould "observe" for drag initiating gestures, the action(s) supported for this Drag and Drop operation, and theDragGestureListenerto notify once a drag initiating gesture has been detected. | 
| Modifier and Type | Method | Description | 
|---|---|---|
| void | addDragGestureListener | Register a new  DragGestureListener. | 
| protected void | appendEvent | Listeners registered on the Component by this Recognizer shall record all Events that are recognized as part of the series of Events that go to comprise a Drag and Drop initiating gesture via this API. | 
| protected void | fireDragGestureRecognized | Notify the DragGestureListener that a Drag and Drop initiating gesture has occurred. | 
| Component | getComponent() | This method returns the  Componentthat is to be "observed" by theDragGestureRecognizerfor drag initiating gestures. | 
| DragSource | getDragSource() | This method returns the  DragSourcethisDragGestureRecognizerwill use in order to process the Drag and Drop operation. | 
| int | getSourceActions() | This method returns an int representing the type of action(s) this Drag and Drop operation will support. | 
| InputEvent | getTriggerEvent() | This method returns the first event in the series of events that initiated the Drag and Drop operation. | 
| protected abstract void | registerListeners() | register this DragGestureRecognizer's Listeners with the Component subclasses must override this method | 
| void | removeDragGestureListener | unregister the current DragGestureListener | 
| void | resetRecognizer() | Reset the Recognizer, if its currently recognizing a gesture, ignore it. | 
| void | setComponent | set the Component that the DragGestureRecognizer is associated with registerListeners() and unregisterListeners() are called as a side effect as appropriate. | 
| void | setSourceActions | This method sets the permitted source drag action(s) for this Drag and Drop operation. | 
| protected abstract void | unregisterListeners() | unregister this DragGestureRecognizer's Listeners with the Component subclasses must override this method | 
protected DragSource dragSource
DragSource associated with this DragGestureRecognizer.protected Component component
Component associated with this DragGestureRecognizer.protected transient DragGestureListener dragGestureListener
DragGestureListener associated with this DragGestureRecognizer.protected int sourceActions
int representing the type(s) of action(s) used in this Drag and Drop operation.protected ArrayList<InputEvent> events
DragGestureRecognizer "recognized" as a "gesture" that triggers a drag.protected DragGestureRecognizer(DragSource ds, Component c, int sa, DragGestureListener dgl)
DragGestureRecognizer given the DragSource to be used in this Drag and Drop operation, the Component this DragGestureRecognizer should "observe" for drag initiating gestures, the action(s) supported for this Drag and Drop operation, and the DragGestureListener to notify once a drag initiating gesture has been detected.ds - the DragSource this DragGestureRecognizer will use to process the Drag and Drop operationc - the Component this DragGestureRecognizer should "observe" the event stream to, in order to detect a drag initiating gesture. If this value is null, the DragGestureRecognizer is not associated with any Component.sa - the set (logical OR) of the DnDConstants that this Drag and Drop operation will supportdgl - the DragGestureRecognizer to notify when a drag gesture is detectedIllegalArgumentException - if ds is null.protected DragGestureRecognizer(DragSource ds, Component c, int sa)
DragGestureRecognizer given the DragSource to be used in this Drag and Drop operation, the Component this DragGestureRecognizer should "observe" for drag initiating gestures, and the action(s) supported for this Drag and Drop operation.ds - the DragSource this DragGestureRecognizer will use to process the Drag and Drop operationc - the Component this DragGestureRecognizer should "observe" the event stream to, in order to detect a drag initiating gesture. If this value is null, the DragGestureRecognizer is not associated with any Component.sa - the set (logical OR) of the DnDConstants that this Drag and Drop operation will supportIllegalArgumentException - if ds is null.protected DragGestureRecognizer(DragSource ds, Component c)
DragGestureRecognizer given the DragSource to be used in this Drag and Drop operation, and the Component this DragGestureRecognizer should "observe" for drag initiating gestures.ds - the DragSource this DragGestureRecognizer will use to process the Drag and Drop operationc - the Component this DragGestureRecognizer should "observe" the event stream to, in order to detect a drag initiating gesture. If this value is null, the DragGestureRecognizer is not associated with any Component.IllegalArgumentException - if ds is null.protected DragGestureRecognizer(DragSource ds)
DragGestureRecognizer given the DragSource to be used in this Drag and Drop operation.ds - the DragSource this DragGestureRecognizer will use to process the Drag and Drop operationIllegalArgumentException - if ds is null.protected abstract void registerListeners()
protected abstract void unregisterListeners()
public DragSource getDragSource()
DragSource this DragGestureRecognizer will use in order to process the Drag and Drop operation.public Component getComponent()
Component that is to be "observed" by the DragGestureRecognizer for drag initiating gestures.public void setComponent(Component c)
c - The Component or null
public int getSourceActions()
public void setSourceActions(int actions)
actions - the permitted source drag action(s)public InputEvent getTriggerEvent()
public void resetRecognizer()
public void addDragGestureListener(DragGestureListener dgl) throws TooManyListenersException
DragGestureListener.dgl - the DragGestureListener to register with this DragGestureRecognizer.TooManyListenersException - if a DragGestureListener has already been added.public void removeDragGestureListener(DragGestureListener dgl)
dgl - the DragGestureListener to unregister from this DragGestureRecognizer
IllegalArgumentException - if dgl is not (equal to) the currently registered DragGestureListener.protected void fireDragGestureRecognized(int dragAction, Point p)
dragAction - The action initially selected by the users gesturep - The point (in Component coords) where the gesture originatedprotected void appendEvent(InputEvent awtie)
 This method is used by a DragGestureRecognizer implementation to add an InputEvent subclass (that it believes is one in a series of events that comprise a Drag and Drop operation) to the array of events that this DragGestureRecognizer maintains internally.
awtie - the InputEvent to add to this DragGestureRecognizer's internal array of events. Note that null is not a valid value, and will be ignored.
    © 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/DragGestureRecognizer.html