APIdia Launch Partner
Top Description Fields Constructors Methods
java.awt.dnd

public Class DragSourceDragEvent

extends DragSourceEvent
Class Inheritance
Imports
java.awt.event.InputEvent, java.io.Serial

The DragSourceDragEvent is delivered from the DragSourceContextPeer, via the DragSourceContext, to the DragSourceListener registered with that DragSourceContext and with its associated DragSource.

The DragSourceDragEvent reports the target drop action and the user drop action that reflect the current state of the drag operation.

Target drop action is one of DnDConstants that represents the drop action selected by the current drop target if this drop action is supported by the drag source or DnDConstants.ACTION_NONE if this drop action is not supported by the drag source.

User drop action depends on the drop actions supported by the drag source and the drop action selected by the user. The user can select a drop action by pressing modifier keys during the drag operation:

  Ctrl + Shift -> ACTION_LINK
  Ctrl         -> ACTION_COPY
  Shift        -> ACTION_MOVE
If the user selects a drop action, the user drop action is one of DnDConstants that represents the selected drop action if this drop action is supported by the drag source or DnDConstants.ACTION_NONE if this drop action is not supported by the drag source.

If the user doesn't select a drop action, the set of DnDConstants that represents the set of drop actions supported by the drag source is searched for DnDConstants.ACTION_MOVE, then for DnDConstants.ACTION_COPY, then for DnDConstants.ACTION_LINK and the user drop action is the first constant found. If no constant is found the user drop action is DnDConstants.ACTION_NONE.

Since
1.2

Field Summary

Modifier and TypeField and Description
private int
dropAction

The user drop action.

private int
gestureModifiers

The state of the input device modifiers associated with the user gesture.

private boolean
invalidModifiers

Indicates whether the gestureModifiers are invalid.

private static final int
private static final int
private static final long
serialVersionUID

Hides java.awt.dnd.DragSourceEvent.serialVersionUID.

Use serialVersionUID from JDK 1.4 for interoperability.
private int
targetActions

The target drop action.

Constructor Summary

AccessConstructor and Description
public
DragSourceDragEvent(DragSourceContext
the DragSourceContext that is to manage notifications for this event.
dsc
,
int
the user drop action.
dropAction
,
int
the target drop action.
action
,
int
the modifier keys down during event (shift, ctrl, alt, meta) Either extended _DOWN_MASK or old _MASK modifiers should be used, but both models should not be mixed in one event. Use of the extended modifiers is preferred.
modifiers
)

Constructs a DragSourceDragEvent.

public
DragSourceDragEvent(DragSourceContext
the DragSourceContext associated with this event.
dsc
,
int
the user drop action.
dropAction
,
int
the target drop action.
action
,
int
the modifier keys down during event (shift, ctrl, alt, meta) Either extended _DOWN_MASK or old _MASK modifiers should be used, but both models should not be mixed in one event. Use of the extended modifiers is preferred.
modifiers
,
int
the horizontal coordinate for the cursor location
x
,
int
the vertical coordinate for the cursor location
y
)

Constructs a DragSourceDragEvent given the specified DragSourceContext, user drop action, target drop action, modifiers and coordinates.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the logical intersection of the target drop action and the set of drop actions supported by the drag source.
getDropAction
()

This method returns the logical intersection of the target drop action and the set of drop actions supported by the drag source.

public int

Returns:

the current state of the input device modifiers
getGestureModifiers
()

This method returns an int representing the current state of the input device modifiers associated with the user's gesture.

public int

Returns:

the current state of the input device extended modifiers
getGestureModifiersEx
()

This method returns an int representing the current state of the input device extended modifiers associated with the user's gesture.

public int

Returns:

the target drop action.
getTargetActions
()

This method returns the target drop action.

public int

Returns:

the user drop action.
getUserAction
()

This method returns the user drop action.

private void
setNewModifiers()

Sets new modifiers by the old ones.

private void
setOldModifiers()

Sets old modifiers by the new ones.

Inherited from java.awt.dnd.DragSourceEvent:
getDragSourceContextgetLocationgetXgetY

Field Detail

dropActionback to summary
private int dropAction

The user drop action.

gestureModifiersback to summary
private int gestureModifiers

The state of the input device modifiers associated with the user gesture.

invalidModifiersback to summary
private boolean invalidModifiers

Indicates whether the gestureModifiers are invalid.

JDK_1_3_MODIFIERSback to summary
private static final int JDK_1_3_MODIFIERS
JDK_1_4_MODIFIERSback to summary
private static final int JDK_1_4_MODIFIERS
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.awt.dnd.DragSourceEvent.serialVersionUID.

Use serialVersionUID from JDK 1.4 for interoperability.

Annotations
@Serial
targetActionsback to summary
private int targetActions

The target drop action.

Constructor Detail

DragSourceDragEventback to summary
public DragSourceDragEvent(DragSourceContext dsc, int dropAction, int action, int modifiers)

Constructs a DragSourceDragEvent. This class is typically instantiated by the DragSourceContextPeer rather than directly by client code. The coordinates for this DragSourceDragEvent are not specified, so getLocation will return null for this event.

The arguments dropAction and action should be one of DnDConstants that represents a single action. The argument modifiers should be either a bitwise mask of old java.awt.event.InputEvent.*_MASK constants or a bitwise mask of extended java.awt.event.InputEvent.*_DOWN_MASK constants. This constructor does not throw any exception for invalid dropAction, action and modifiers.

Parameters
dsc:DragSourceContext

the DragSourceContext that is to manage notifications for this event.

dropAction:int

the user drop action.

action:int

the target drop action.

modifiers:int

the modifier keys down during event (shift, ctrl, alt, meta) Either extended _DOWN_MASK or old _MASK modifiers should be used, but both models should not be mixed in one event. Use of the extended modifiers is preferred.

Exceptions
IllegalArgumentException:
if dsc is null.
See Also
java.awt.event.InputEvent, DragSourceEvent#getLocation
DragSourceDragEventback to summary
public DragSourceDragEvent(DragSourceContext dsc, int dropAction, int action, int modifiers, int x, int y)

Constructs a DragSourceDragEvent given the specified DragSourceContext, user drop action, target drop action, modifiers and coordinates.

The arguments dropAction and action should be one of DnDConstants that represents a single action. The argument modifiers should be either a bitwise mask of old java.awt.event.InputEvent.*_MASK constants or a bitwise mask of extended java.awt.event.InputEvent.*_DOWN_MASK constants. This constructor does not throw any exception for invalid dropAction, action and modifiers.

Parameters
dsc:DragSourceContext

the DragSourceContext associated with this event.

dropAction:int

the user drop action.

action:int

the target drop action.

modifiers:int

the modifier keys down during event (shift, ctrl, alt, meta) Either extended _DOWN_MASK or old _MASK modifiers should be used, but both models should not be mixed in one event. Use of the extended modifiers is preferred.

x:int

the horizontal coordinate for the cursor location

y:int

the vertical coordinate for the cursor location

Exceptions
IllegalArgumentException:
if dsc is null.
Since
1.4
See Also
java.awt.event.InputEvent

Method Detail

getDropActionback to summary
public int getDropAction()

This method returns the logical intersection of the target drop action and the set of drop actions supported by the drag source.

Returns:int

the logical intersection of the target drop action and the set of drop actions supported by the drag source.

getGestureModifiersback to summary
public int getGestureModifiers()

This method returns an int representing the current state of the input device modifiers associated with the user's gesture. Typically these would be mouse buttons or keyboard modifiers.

If the modifiers passed to the constructor are invalid, this method returns them unchanged.

Returns:int

the current state of the input device modifiers

getGestureModifiersExback to summary
public int getGestureModifiersEx()

This method returns an int representing the current state of the input device extended modifiers associated with the user's gesture. See InputEvent#getModifiersEx

If the modifiers passed to the constructor are invalid, this method returns them unchanged.

Returns:int

the current state of the input device extended modifiers

Since
1.4
getTargetActionsback to summary
public int getTargetActions()

This method returns the target drop action.

Returns:int

the target drop action.

getUserActionback to summary
public int getUserAction()

This method returns the user drop action.

Returns:int

the user drop action.

setNewModifiersback to summary
private void setNewModifiers()

Sets new modifiers by the old ones. The mouse modifiers have higher priority than overlaying key modifiers.

Annotations
@SuppressWarnings:deprecation
setOldModifiersback to summary
private void setOldModifiers()

Sets old modifiers by the new ones.

Annotations
@SuppressWarnings:deprecation