- java.lang.Object
-
- java.awt.dnd.DragGestureRecognizer
-
- All Implemented Interfaces:
- Serializable
- Direct Known Subclasses:
- MouseDragGestureRecognizer
public abstract class DragGestureRecognizer extends Object implements Serializable
TheDragGestureRecognizer
is an abstract base class for the specification of a platform-dependent listener that can be associated with a particularComponent
in order to identify platform-dependent drag initiating gestures.The appropriate
DragGestureRecognizer
subclass instance is obtained from theDragSource
asssociated with a particularComponent
, or from theToolkit
object via itscreateDragGestureRecognizer()
method.Once the
DragGestureRecognizer
is associated with a particularComponent
it will register the appropriate listener interfaces on thatComponent
in order to track the input events delivered to theComponent
.Once the
DragGestureRecognizer
identifies a sequence of events on theComponent
as a drag initiating gesture, it will notify its unicastDragGestureListener
by invoking itsgestureRecognized()
method.When a concrete
DragGestureRecognizer
instance detects a drag initiating gesture on theComponent
it is associated with, it fires aDragGestureEvent
to theDragGestureListener
registered on its unicast event source forDragGestureListener
events. ThisDragGestureListener
is responsible for causing the associatedDragSource
to start the Drag and Drop operation (if appropriate).- See Also:
DragGestureListener
,DragGestureEvent
,DragSource
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description protected Component
component
TheComponent
associated with thisDragGestureRecognizer
.protected DragGestureListener
dragGestureListener
TheDragGestureListener
associated with thisDragGestureRecognizer
.protected DragSource
dragSource
TheDragSource
associated with thisDragGestureRecognizer
.protected ArrayList<InputEvent>
events
The list of events (in order) that theDragGestureRecognizer
"recognized" as a "gesture" that triggers a drag.protected int
sourceActions
Anint
representing the type(s) of action(s) used in this Drag and Drop operation.
-
Constructor Summary
Constructors Modifier Constructor and Description protected
DragGestureRecognizer(DragSource ds)
Construct a newDragGestureRecognizer
given theDragSource
to be used in this Drag and Drop operation.protected
DragGestureRecognizer(DragSource ds, Component c)
Construct a newDragGestureRecognizer
given theDragSource
to be used in this Drag and Drop operation, and theComponent
thisDragGestureRecognizer
should "observe" for drag initiating gestures.protected
DragGestureRecognizer(DragSource ds, Component c, int sa)
Construct a newDragGestureRecognizer
given theDragSource
to be used in this Drag and Drop operation, theComponent
thisDragGestureRecognizer
should "observe" for drag initiating gestures, and the action(s) supported for this Drag and Drop operation.protected
DragGestureRecognizer(DragSource ds, Component c, int sa, DragGestureListener dgl)
Construct a newDragGestureRecognizer
given theDragSource
to be used in this Drag and Drop operation, theComponent
thisDragGestureRecognizer
should "observe" for drag initiating gestures, the action(s) supported for this Drag and Drop operation, and theDragGestureListener
to notify once a drag initiating gesture has been detected.
-
Method Summary
Methods Modifier and Type Method and Description void
addDragGestureListener(DragGestureListener dgl)
Register a newDragGestureListener
.protected 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.protected void
fireDragGestureRecognized(int dragAction, Point p)
Notify the DragGestureListener that a Drag and Drop initiating gesture has occurred.Component
getComponent()
This method returns theComponent
that is to be "observed" by theDragGestureRecognizer
for drag initiating gestures.DragSource
getDragSource()
This method returns theDragSource
thisDragGestureRecognizer
will 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 methodvoid
removeDragGestureListener(DragGestureListener dgl)
unregister the current DragGestureListenervoid
resetRecognizer()
Reset the Recognizer, if its currently recognizing a gesture, ignore it.void
setComponent(Component c)
set the Component that the DragGestureRecognizer is associated with registerListeners() and unregisterListeners() are called as a side effect as appropriate.void
setSourceActions(int actions)
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
-
-
-
Field Detail
-
dragSource
protected DragSource dragSource
TheDragSource
associated with thisDragGestureRecognizer
.
-
component
protected Component component
TheComponent
associated with thisDragGestureRecognizer
.
-
dragGestureListener
protected transient DragGestureListener dragGestureListener
TheDragGestureListener
associated with thisDragGestureRecognizer
.
-
sourceActions
protected int sourceActions
Anint
representing the type(s) of action(s) used in this Drag and Drop operation.
-
events
protected ArrayList<InputEvent> events
The list of events (in order) that theDragGestureRecognizer
"recognized" as a "gesture" that triggers a drag.
-
-
Constructor Detail
-
DragGestureRecognizer
protected DragGestureRecognizer(DragSource ds, Component c, int sa, DragGestureListener dgl)
Construct a newDragGestureRecognizer
given theDragSource
to be used in this Drag and Drop operation, theComponent
thisDragGestureRecognizer
should "observe" for drag initiating gestures, the action(s) supported for this Drag and Drop operation, and theDragGestureListener
to notify once a drag initiating gesture has been detected.- Parameters:
ds
- theDragSource
thisDragGestureRecognizer
will use to process the Drag and Drop operationc
- theComponent
thisDragGestureRecognizer
should "observe" the event stream to, in order to detect a drag initiating gesture. If this value isnull
, theDragGestureRecognizer
is not associated with anyComponent
.sa
- the set (logical OR) of theDnDConstants
that this Drag and Drop operation will supportdgl
- theDragGestureRecognizer
to notify when a drag gesture is detected- Throws:
- if ds isIllegalArgumentException
null
.
-
DragGestureRecognizer
protected DragGestureRecognizer(DragSource ds, Component c, int sa)
Construct a newDragGestureRecognizer
given theDragSource
to be used in this Drag and Drop operation, theComponent
thisDragGestureRecognizer
should "observe" for drag initiating gestures, and the action(s) supported for this Drag and Drop operation.- Parameters:
ds
- theDragSource
thisDragGestureRecognizer
will use to process the Drag and Drop operationc
- theComponent
thisDragGestureRecognizer
should "observe" the event stream to, in order to detect a drag initiating gesture. If this value isnull
, theDragGestureRecognizer
is not associated with anyComponent
.sa
- the set (logical OR) of theDnDConstants
that this Drag and Drop operation will support- Throws:
- if ds isIllegalArgumentException
null
.
-
DragGestureRecognizer
protected DragGestureRecognizer(DragSource ds, Component c)
Construct a newDragGestureRecognizer
given theDragSource
to be used in this Drag and Drop operation, and theComponent
thisDragGestureRecognizer
should "observe" for drag initiating gestures.- Parameters:
ds
- theDragSource
thisDragGestureRecognizer
will use to process the Drag and Drop operationc
- theComponent
thisDragGestureRecognizer
should "observe" the event stream to, in order to detect a drag initiating gesture. If this value isnull
, theDragGestureRecognizer
is not associated with anyComponent
.- Throws:
- if ds isIllegalArgumentException
null
.
-
DragGestureRecognizer
protected DragGestureRecognizer(DragSource ds)
Construct a newDragGestureRecognizer
given theDragSource
to be used in this Drag and Drop operation.- Parameters:
ds
- theDragSource
thisDragGestureRecognizer
will use to process the Drag and Drop operation- Throws:
- if ds isIllegalArgumentException
null
.
-
-
Method Detail
-
registerListeners
protected abstract void registerListeners()
register this DragGestureRecognizer's Listeners with the Component subclasses must override this method
-
unregisterListeners
protected abstract void unregisterListeners()
unregister this DragGestureRecognizer's Listeners with the Component subclasses must override this method
-
getDragSource
public DragSource getDragSource()
This method returns theDragSource
thisDragGestureRecognizer
will use in order to process the Drag and Drop operation.- Returns:
- the DragSource
-
getComponent
public Component getComponent()
This method returns theComponent
that is to be "observed" by theDragGestureRecognizer
for drag initiating gestures.- Returns:
- The Component this DragGestureRecognizer is associated with
-
setComponent
public 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
- TheComponent
ornull
-
getSourceActions
public 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)
-
setSourceActions
public 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)
-
getTriggerEvent
public 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
-
resetRecognizer
public void resetRecognizer()
Reset the Recognizer, if its currently recognizing a gesture, ignore it.
-
addDragGestureListener
public void addDragGestureListener(DragGestureListener dgl) throws TooManyListenersException
Register a newDragGestureListener
.- Parameters:
dgl
- theDragGestureListener
to register with thisDragGestureRecognizer
.- Throws:
TooManyListenersException
- if aDragGestureListener
has already been added.
-
removeDragGestureListener
public void removeDragGestureListener(DragGestureListener dgl)
unregister the current DragGestureListener- Parameters:
dgl
- theDragGestureListener
to unregister from thisDragGestureRecognizer
- Throws:
- if dgl is not (equal to) the currently registeredIllegalArgumentException
DragGestureListener
.
-
fireDragGestureRecognized
protected 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 gesturep
- The point (in Component coords) where the gesture originated
-
appendEvent
protected 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
DragGestureRecognizer
implementation to add anInputEvent
subclass (that it believes is one in a series of events that comprise a Drag and Drop operation) to the array of events that thisDragGestureRecognizer
maintains internally.- Parameters:
awtie
- theInputEvent
to add to thisDragGestureRecognizer
's internal array of events. Note thatnull
is not a valid value, and will be ignored.
-
-
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 04/03/2020
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-rf-java/awt/dnd/draggesturerecognizer.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.