- java.lang.Object
- 
- java.awt.dnd.DragGestureRecognizer
 
- 
- All Implemented Interfaces:
- Serializable
 - Direct Known Subclasses:
- MouseDragGestureRecognizer
 
 public abstract class DragGestureRecognizer extends Object implements Serializable TheDragGestureRecognizeris an abstract base class for the specification of a platform-dependent listener that can be associated with a particularComponentin order to identify platform-dependent drag initiating gestures.The appropriate DragGestureRecognizersubclass instance is obtained from theDragSourceassociated with a particularComponent, or from theToolkitobject via itscreateDragGestureRecognizer()method.Once the DragGestureRecognizeris associated with a particularComponentit will register the appropriate listener interfaces on thatComponentin order to track the input events delivered to theComponent.Once the DragGestureRecognizeridentifies a sequence of events on theComponentas a drag initiating gesture, it will notify its unicastDragGestureListenerby invoking itsgestureRecognized()method.When a concrete DragGestureRecognizerinstance detects a drag initiating gesture on theComponentit is associated with, it fires aDragGestureEventto theDragGestureListenerregistered on its unicast event source forDragGestureListenerevents. ThisDragGestureListeneris responsible for causing the associatedDragSourceto start the Drag and Drop operation (if appropriate).- See Also:
- DragGestureListener,- DragGestureEvent,- DragSource, Serialized Form
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected ComponentcomponentTheComponentassociated with thisDragGestureRecognizer.protected DragGestureListenerdragGestureListenerTheDragGestureListenerassociated with thisDragGestureRecognizer.protected DragSourcedragSourceTheDragSourceassociated with thisDragGestureRecognizer.protected ArrayList<InputEvent>eventsThe list of events (in order) that theDragGestureRecognizer"recognized" as a "gesture" that triggers a drag.protected intsourceActionsAnintrepresenting the type(s) of action(s) used in this Drag and Drop operation.
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedDragGestureRecognizer(DragSource ds)Construct a newDragGestureRecognizergiven theDragSourceto be used in this Drag and Drop operation.protectedDragGestureRecognizer(DragSource ds, Component c)Construct a newDragGestureRecognizergiven theDragSourceto be used in this Drag and Drop operation, and theComponentthisDragGestureRecognizershould "observe" for drag initiating gestures.protectedDragGestureRecognizer(DragSource ds, Component c, int sa)Construct a newDragGestureRecognizergiven 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.protectedDragGestureRecognizer(DragSource ds, Component c, int sa, DragGestureListener dgl)Construct a newDragGestureRecognizergiven 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.
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddDragGestureListener(DragGestureListener dgl)Register a newDragGestureListener.protected voidappendEvent(InputEvent awtie)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 voidfireDragGestureRecognized(int dragAction, Point p)Notify the DragGestureListener that a Drag and Drop initiating gesture has occurred.ComponentgetComponent()This method returns theComponentthat is to be "observed" by theDragGestureRecognizerfor drag initiating gestures.DragSourcegetDragSource()This method returns theDragSourcethisDragGestureRecognizerwill use in order to process the Drag and Drop operation.intgetSourceActions()This method returns an int representing the type of action(s) this Drag and Drop operation will support.InputEventgetTriggerEvent()This method returns the first event in the series of events that initiated the Drag and Drop operation.protected abstract voidregisterListeners()register this DragGestureRecognizer's Listeners with the Component subclasses must override this methodvoidremoveDragGestureListener(DragGestureListener dgl)unregister the current DragGestureListenervoidresetRecognizer()Reset the Recognizer, if its currently recognizing a gesture, ignore it.voidsetComponent(Component c)set the Component that the DragGestureRecognizer is associated with registerListeners() and unregisterListeners() are called as a side effect as appropriate.voidsetSourceActions(int actions)This method sets the permitted source drag action(s) for this Drag and Drop operation.protected abstract voidunregisterListeners()unregister this DragGestureRecognizer's Listeners with the Component subclasses must override this method
 
- 
- 
- 
Field Detail- 
dragSourceprotected DragSource dragSource TheDragSourceassociated with thisDragGestureRecognizer.
 - 
componentprotected Component component TheComponentassociated with thisDragGestureRecognizer.
 - 
dragGestureListenerprotected transient DragGestureListener dragGestureListener TheDragGestureListenerassociated with thisDragGestureRecognizer.
 - 
sourceActionsprotected int sourceActions Anintrepresenting the type(s) of action(s) used in this Drag and Drop operation.
 - 
eventsprotected ArrayList<InputEvent> events The list of events (in order) that theDragGestureRecognizer"recognized" as a "gesture" that triggers a drag.
 
- 
 - 
Constructor Detail- 
DragGestureRecognizerprotected DragGestureRecognizer(DragSource ds, Component c, int sa, DragGestureListener dgl) Construct a newDragGestureRecognizergiven 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.- Parameters:
- ds- the- DragSourcethis- DragGestureRecognizerwill use to process the Drag and Drop operation
- c- the- Componentthis- DragGestureRecognizershould "observe" the event stream to, in order to detect a drag initiating gesture. If this value is- null, the- DragGestureRecognizeris not associated with any- Component.
- sa- the set (logical OR) of the- DnDConstantsthat this Drag and Drop operation will support
- dgl- the- DragGestureRecognizerto notify when a drag gesture is detected
- Throws:
- IllegalArgumentException- if ds is- null.
 
 - 
DragGestureRecognizerprotected DragGestureRecognizer(DragSource ds, Component c, int sa) Construct a newDragGestureRecognizergiven 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.- Parameters:
- ds- the- DragSourcethis- DragGestureRecognizerwill use to process the Drag and Drop operation
- c- the- Componentthis- DragGestureRecognizershould "observe" the event stream to, in order to detect a drag initiating gesture. If this value is- null, the- DragGestureRecognizeris not associated with any- Component.
- sa- the set (logical OR) of the- DnDConstantsthat this Drag and Drop operation will support
- Throws:
- IllegalArgumentException- if ds is- null.
 
 - 
DragGestureRecognizerprotected DragGestureRecognizer(DragSource ds, Component c) Construct a newDragGestureRecognizergiven theDragSourceto be used in this Drag and Drop operation, and theComponentthisDragGestureRecognizershould "observe" for drag initiating gestures.- Parameters:
- ds- the- DragSourcethis- DragGestureRecognizerwill use to process the Drag and Drop operation
- c- the- Componentthis- DragGestureRecognizershould "observe" the event stream to, in order to detect a drag initiating gesture. If this value is- null, the- DragGestureRecognizeris not associated with any- Component.
- Throws:
- IllegalArgumentException- if ds is- null.
 
 - 
DragGestureRecognizerprotected DragGestureRecognizer(DragSource ds) Construct a newDragGestureRecognizergiven theDragSourceto be used in this Drag and Drop operation.- Parameters:
- ds- the- DragSourcethis- DragGestureRecognizerwill use to process the Drag and Drop operation
- Throws:
- IllegalArgumentException- if ds is- null.
 
 
- 
 - 
Method Detail- 
registerListenersprotected abstract void registerListeners() register this DragGestureRecognizer's Listeners with the Component subclasses must override this method
 - 
unregisterListenersprotected abstract void unregisterListeners() unregister this DragGestureRecognizer's Listeners with the Component subclasses must override this method
 - 
getDragSourcepublic DragSource getDragSource() This method returns theDragSourcethisDragGestureRecognizerwill use in order to process the Drag and Drop operation.- Returns:
- the DragSource
 
 - 
getComponentpublic Component getComponent() This method returns theComponentthat is to be "observed" by theDragGestureRecognizerfor drag initiating gestures.- Returns:
- The Component this DragGestureRecognizer is associated with
 
 - 
setComponentpublic void setComponent(Component c) set the Component that the DragGestureRecognizer is associated with registerListeners() and unregisterListeners() are called as a side effect as appropriate.- Parameters:
- c- The- Componentor- null
 
 - 
getSourceActionspublic int getSourceActions() This method returns an int representing the type of action(s) this Drag and Drop operation will support.- Returns:
- the currently permitted source action(s)
 
 - 
setSourceActionspublic void setSourceActions(int actions) This method sets the permitted source drag action(s) for this Drag and Drop operation.- Parameters:
- actions- the permitted source drag action(s)
 
 - 
getTriggerEventpublic InputEvent getTriggerEvent() This method returns the first event in the series of events that initiated the Drag and Drop operation.- Returns:
- the initial event that triggered the drag gesture
 
 - 
resetRecognizerpublic void resetRecognizer() Reset the Recognizer, if its currently recognizing a gesture, ignore it.
 - 
addDragGestureListenerpublic void addDragGestureListener(DragGestureListener dgl) throws TooManyListenersException Register a newDragGestureListener.- Parameters:
- dgl- the- DragGestureListenerto register with this- DragGestureRecognizer.
- Throws:
- TooManyListenersException- if a- DragGestureListenerhas already been added.
 
 - 
removeDragGestureListenerpublic void removeDragGestureListener(DragGestureListener dgl) unregister the current DragGestureListener- Parameters:
- dgl- the- DragGestureListenerto unregister from this- DragGestureRecognizer
- Throws:
- IllegalArgumentException- if dgl is not (equal to) the currently registered- DragGestureListener.
 
 - 
fireDragGestureRecognizedprotected void fireDragGestureRecognized(int dragAction, Point p)Notify the DragGestureListener that a Drag and Drop initiating gesture has occurred. Then reset the state of the Recognizer.- Parameters:
- dragAction- The action initially selected by the users gesture
- p- The point (in Component coords) where the gesture originated
 
 - 
appendEventprotected void appendEvent(InputEvent awtie) 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.This method is used by a DragGestureRecognizerimplementation to add anInputEventsubclass (that it believes is one in a series of events that comprise a Drag and Drop operation) to the array of events that thisDragGestureRecognizermaintains internally.- Parameters:
- awtie- the- InputEventto add to this- DragGestureRecognizer's internal array of events. Note that- nullis not a valid value, and will be ignored.
 
 
- 
 
-