- java.lang.Object
-
- java.util.EventObject
-
- java.awt.dnd.DragGestureEvent
-
- All Implemented Interfaces:
- Serializable
public class DragGestureEvent extends EventObject
ADragGestureEventis passed toDragGestureListener's dragGestureRecognized() method when a particularDragGestureRecognizerdetects that a platform dependent drag initiating gesture has occurred on theComponentthat it is tracking. Theactionfield of anyDragGestureEventinstance should take one of the following values:-
DnDConstants.ACTION_COPY -
DnDConstants.ACTION_MOVE -
DnDConstants.ACTION_LINK
-
-
Field Summary
-
Fields inherited from class java.util.EventObject
source
-
-
Constructor Summary
Constructors Constructor and Description DragGestureEvent(DragGestureRecognizer dgr, int act, Point ori, List<? extends InputEvent> evs)Constructs aDragGestureEventobject given by theDragGestureRecognizerinstance firing this event, anactparameter representing the user's preferred action, anoriparameter indicating the origin of the drag, and aListof events that comprise the gesture(evsparameter).
-
Method Summary
Methods Modifier and Type Method and Description ComponentgetComponent()Returns theComponentassociated with thisDragGestureEvent.intgetDragAction()Returns anintrepresenting the action selected by the user.PointgetDragOrigin()Returns aPointin the coordinates of theComponentover which the drag originated.DragSourcegetDragSource()Returns theDragSource.DragGestureRecognizergetSourceAsDragGestureRecognizer()Returns the source as aDragGestureRecognizer.InputEventgetTriggerEvent()Returns the initial event that triggered the gesture.Iterator<InputEvent>iterator()Returns anIteratorfor the events comprising the gesture.voidstartDrag(Cursor dragCursor, Image dragImage, Point imageOffset, Transferable transferable, DragSourceListener dsl)Start the drag given the initialCursorto display, a dragImage, the offset of theImage, theTransferableobject, and theDragSourceListenerto use.voidstartDrag(Cursor dragCursor, Transferable transferable)Starts the drag operation given theCursorfor this drag operation and theTransferablerepresenting the source data for this drag operation.voidstartDrag(Cursor dragCursor, Transferable transferable, DragSourceListener dsl)Starts the drag given the initialCursorto display, theTransferableobject, and theDragSourceListenerto use.Object[]toArray()Returns anObjectarray of the events comprising the drag gesture.Object[]toArray(Object[] array)Returns an array of the events comprising the drag gesture.
-
-
-
Constructor Detail
-
DragGestureEvent
public DragGestureEvent(DragGestureRecognizer dgr, int act, Point ori, List<? extends InputEvent> evs)
Constructs aDragGestureEventobject given by theDragGestureRecognizerinstance firing this event, anactparameter representing the user's preferred action, anoriparameter indicating the origin of the drag, and aListof events that comprise the gesture(evsparameter).- Parameters:
dgr- TheDragGestureRecognizerfiring this eventact- The user's preferred action. For information on allowable values, see the class description forDragGestureEventori- The origin of the dragevs- TheListof events that comprise the gesture- Throws:
IllegalArgumentException- if any parameter equalsnullIllegalArgumentException- if the act parameter does not comply with the values given in the class description forDragGestureEvent- See Also:
DnDConstants
-
-
Method Detail
-
getSourceAsDragGestureRecognizer
public DragGestureRecognizer getSourceAsDragGestureRecognizer()
Returns the source as aDragGestureRecognizer.- Returns:
- the source as a
DragGestureRecognizer
-
getComponent
public Component getComponent()
Returns theComponentassociated with thisDragGestureEvent.- Returns:
- the Component
-
getDragSource
public DragSource getDragSource()
Returns theDragSource.- Returns:
- the
DragSource
-
getDragOrigin
public Point getDragOrigin()
Returns aPointin the coordinates of theComponentover which the drag originated.- Returns:
- the Point where the drag originated in Component coords.
-
iterator
public Iterator<InputEvent> iterator()
Returns anIteratorfor the events comprising the gesture.- Returns:
- an Iterator for the events comprising the gesture
-
toArray
public Object[] toArray()
Returns anObjectarray 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 ofEventObjectsub(types)- Returns:
- an array of the events comprising the gesture
-
getDragAction
public int getDragAction()
Returns anintrepresenting 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 theCursorfor this drag operation and theTransferablerepresenting the source data for this drag operation.
If anullCursoris specified no exception will be thrown and default drag cursors will be used instead.
If anullTransferableis specifiedNullPointerExceptionwill be thrown.- Parameters:
dragCursor- The initialCursorfor this drag operation ornullfor the default cursor handling; see DragSourceContext for more details on the cursor handling mechanism during drag and droptransferable- TheTransferablerepresenting 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 theTransferableisnull- Since:
- 1.4
-
startDrag
public void startDrag(Cursor dragCursor, Transferable transferable, DragSourceListener dsl) throws InvalidDnDOperationException
Starts the drag given the initialCursorto display, theTransferableobject, and theDragSourceListenerto use.- Parameters:
dragCursor- The initialCursorfor this drag operation ornullfor 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 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 initialCursorto display, a dragImage, the offset of theImage, theTransferableobject, and theDragSourceListenerto use.- Parameters:
dragCursor- The initialCursorfor this drag operation ornullfor 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 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.
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
15/09/2025 12:13:07 Cette version de la page est en cache (à la date du 15/09/2025 12:13:07) afin d'accélérer le traitement.Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la version plus récente de la page.
Document créé le 31/08/2006, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-java/awt/dnd/draggestureevent.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.