Top Description Fields Constructors Methods
java.awt.dnd

public Class DragGestureEvent

extends EventObject
Class Inheritance
Imports
java.awt.Component, .Cursor, .Image, .Point, java.awt.datatransfer.Transferable, java.awt.event.InputEvent, java.io.IOException, .InvalidObjectException, .ObjectInputStream, .ObjectOutputStream, .Serial, java.util.Collections, .EventObject, .Iterator, .List

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

Field Summary

Modifier and TypeField and Description
private int
action

The user's preferred action.

private Component
component

The Component associated with this DragGestureEvent.

private DragSource
dragSource

The DragSource associated with this DragGestureEvent.

private transient List<E>
private Point
origin

The origin of the drag.

private static final long
serialVersionUID

Hides java.util.EventObject.serialVersionUID.

Use serialVersionUID from JDK 1.4 for interoperability.
Inherited from java.util.EventObject:
source

Constructor Summary

AccessConstructor and Description
public
DragGestureEvent(DragGestureRecognizer
The DragGestureRecognizer firing this event
dgr
,
int
The user's preferred action. For information on allowable values, see the class description for DragGestureEvent
act
,
Point
The origin of the drag
ori
,
List<? extends InputEvent>
The List of events that comprise the gesture
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 TypeMethod and Description
public Component

Returns:

the Component
getComponent
()

Returns the Component associated with this DragGestureEvent.

public int

Returns:

the action selected by the user
getDragAction
()

Returns an int representing the action selected by the user.

public Point

Returns:

the Point where the drag originated in Component coords.
getDragOrigin
()

Returns a Point in the coordinates of the Component over which the drag originated.

public DragSource

Returns:

the DragSource
getDragSource
()

Returns the DragSource.

public DragGestureRecognizer

Returns:

the source as a DragGestureRecognizer
getSourceAsDragGestureRecognizer
()

Returns the source as a DragGestureRecognizer.

public InputEvent

Returns:

the first "triggering" event in the sequence of the gesture
getTriggerEvent
()

Returns the initial event that triggered the gesture.

public Iterator<InputEvent>

Returns:

an Iterator for the events comprising the gesture
iterator
()

Returns an Iterator for the events comprising the gesture.

private void
readObject(ObjectInputStream
the ObjectInputStream to read
s
)

Deserializes this DragGestureEvent.

public void
startDrag(Cursor
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
dragCursor
,
Transferable
The Transferable representing the source data for this drag operation.
transferable
)

Starts the drag operation given the Cursor for this drag operation and the Transferable representing the source data for this drag operation.

public void
startDrag(Cursor
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
dragCursor
,
Transferable
The source's Transferable
transferable
,
DragSourceListener
The source's DragSourceListener
dsl
)

Starts the drag given the initial Cursor to display, the Transferable object, and the DragSourceListener to use.

public void
startDrag(Cursor
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
dragCursor
,
Image
The source's dragImage
dragImage
,
Point
The dragImage's offset
imageOffset
,
Transferable
The source's Transferable
transferable
,
DragSourceListener
The source's 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.

public Object[]

Returns:

an array of the events comprising the gesture
toArray
()

Returns an Object array of the events comprising the drag gesture.

public Object[]

Returns:

an array of the events comprising the gesture
toArray
(Object[]
the array of EventObject sub(types)
array
)

Returns an array of the events comprising the drag gesture.

private void
writeObject(ObjectOutputStream
the ObjectOutputStream to write
s
)

Serializes this DragGestureEvent.

Inherited from java.util.EventObject:
getSourcetoString

Field Detail

actionback to summary
private int action

The user's preferred action.

componentback to summary
private Component component

The Component associated with this DragGestureEvent.

dragSourceback to summary
private DragSource dragSource

The DragSource associated with this DragGestureEvent.

eventsback to summary
private transient List<E> events
Annotations
@SuppressWarnings:rawtypes
originback to summary
private Point origin

The origin of the drag.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.EventObject.serialVersionUID.

Use serialVersionUID from JDK 1.4 for interoperability.

Annotations
@Serial

Constructor Detail

DragGestureEventback to summary
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:DragGestureRecognizer

The DragGestureRecognizer firing this event

act:int

The user's preferred action. For information on allowable values, see the class description for DragGestureEvent

ori:Point

The origin of the drag

evs:List<? extends InputEvent>

The List of events that comprise the gesture

Exceptions
IllegalArgumentException:
  • if any parameter equals null
  • if the act parameter does not comply with the values given in the class description for DragGestureEvent
See Also
java.awt.dnd.DnDConstants

Method Detail

getComponentback to summary
public Component getComponent()

Returns the Component associated with this DragGestureEvent.

Returns:Component

the Component

getDragActionback to summary
public int getDragAction()

Returns an int representing the action selected by the user.

Returns:int

the action selected by the user

getDragOriginback to summary
public Point getDragOrigin()

Returns a Point in the coordinates of the Component over which the drag originated.

Returns:Point

the Point where the drag originated in Component coords.

getDragSourceback to summary
public DragSource getDragSource()

Returns the DragSource.

Returns:DragSource

the DragSource

getSourceAsDragGestureRecognizerback to summary
public DragGestureRecognizer getSourceAsDragGestureRecognizer()

Returns the source as a DragGestureRecognizer.

Returns:DragGestureRecognizer

the source as a DragGestureRecognizer

getTriggerEventback to summary
public InputEvent getTriggerEvent()

Returns the initial event that triggered the gesture.

Returns:InputEvent

the first "triggering" event in the sequence of the gesture

iteratorback to summary
public Iterator<InputEvent> iterator()

Returns an Iterator for the events comprising the gesture.

Returns:Iterator<InputEvent>

an Iterator for the events comprising the gesture

Annotations
@SuppressWarnings:unchecked
readObjectback to summary
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException

Deserializes this DragGestureEvent. This method first performs default deserialization for all non-transient fields. An attempt is then made to deserialize this object's List of gesture events as well. This is first attempted by deserializing the field events, because, in releases prior to 1.4, a non-transient field of this name stored the List of gesture events. If this fails, the next object in the stream is used instead. If the resulting List is null, this object's List of gesture events is set to an empty List.

Parameters
s:ObjectInputStream

the ObjectInputStream to read

Annotations
@Serial
Exceptions
ClassNotFoundException:
if the class of a serialized object could not be found
IOException:
if an I/O error occurs
Since
1.4
startDragback to summary
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:Cursor

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:Transferable

The Transferable representing the source data for this drag operation.

Exceptions
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
startDragback to summary
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:Cursor

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:Transferable

The source's Transferable

dsl:DragSourceListener

The source's DragSourceListener

Exceptions
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.
startDragback to summary
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:Cursor

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:Image

The source's dragImage

imageOffset:Point

The dragImage's offset

transferable:Transferable

The source's Transferable

dsl:DragSourceListener

The source's DragSourceListener

Exceptions
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.
toArrayback to summary
public Object[] toArray()

Returns an Object array of the events comprising the drag gesture.

Returns:Object[]

an array of the events comprising the gesture

toArrayback to summary
public Object[] toArray(Object[] array)

Returns an array of the events comprising the drag gesture.

Parameters
array:Object[]

the array of EventObject sub(types)

Returns:Object[]

an array of the events comprising the gesture

Annotations
@SuppressWarnings:unchecked
writeObjectback to summary
private void writeObject(ObjectOutputStream s) throws IOException

Serializes this DragGestureEvent. Performs default serialization and then writes out this object's List of gesture events if and only if the List can be serialized. If not, null is written instead. In this case, a DragGestureEvent created from the resulting deserialized stream will contain an empty List of gesture events.

Parameters
s:ObjectOutputStream

the ObjectOutputStream to write

Annotations
@Serial
Exceptions
IOException:
if an I/O error occurs
Since
1.4
Serial data
The default serializable fields, in alphabetical order, followed by either a List instance, or null.