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

public Class DropTargetDropEvent

extends DropTargetEvent
Class Inheritance
Imports
java.awt.Point, java.awt.datatransfer.DataFlavor, .Transferable, java.io.Serial, java.util.List

The DropTargetDropEvent is delivered via the DropTargetListener drop() method.

The DropTargetDropEvent reports the source drop actions and the user drop action that reflect the current state of the drag-and-drop operation.

Source drop actions is a bitwise mask of DnDConstants that represents the set of drop actions supported by the drag source for this drag-and-drop operation.

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
actions

The source drop actions.

private int
dropAction

The user drop action.

private boolean
isLocalTx

true if the source is in the same JVM as the target.

private Point
location

The location of the drag cursor's hotspot in Component coordinates.

private static final long
serialVersionUID

Hides java.awt.dnd.DropTargetEvent.serialVersionUID.

Use serialVersionUID from JDK 1.4 for interoperability.
private static final Point
Inherited from java.awt.dnd.DropTargetEvent:
context

Constructor Summary

AccessConstructor and Description
public
DropTargetDropEvent(DropTargetContext
The DropTargetContext for this operation
dtc
,
Point
The location of the "Drag" Cursor's hotspot in Component coordinates
cursorLocn
,
int
the user drop action.
dropAction
,
int
the source drop actions.
srcActions
)

Construct a DropTargetDropEvent given the DropTargetContext for this operation, the location of the drag Cursor's hotspot in the Component's coordinates, the currently selected user drop action, and the current set of actions supported by the source.

public
DropTargetDropEvent(DropTargetContext
The DropTargetContext for this operation
dtc
,
Point
The location of the "Drag" Cursor's hotspot in Component's coordinates
cursorLocn
,
int
the user drop action.
dropAction
,
int
the source drop actions.
srcActions
,
boolean
True if the source is in the same JVM as the target
isLocal
)

Construct a DropTargetEvent given the DropTargetContext for this operation, the location of the drag Cursor's hotspot in the Component's coordinates, the currently selected user drop action, the current set of actions supported by the source, and a boolean indicating if the source is in the same JVM as the target.

Method Summary

Modifier and TypeMethod and Description
public void
acceptDrop(int
the specified action
dropAction
)

accept the drop, using the specified action.

public void
dropComplete(boolean
a boolean indicating that the drop transfer(s) are completed.
success
)

This method notifies the DragSource that the drop transfer(s) are completed.

public DataFlavor[]

Returns:

current DataFlavors
getCurrentDataFlavors
()

This method returns the current DataFlavors.

public List<DataFlavor>

Returns:

the currently available DataFlavors as a java.util.List
getCurrentDataFlavorsAsList
()

This method returns the currently available DataFlavors as a java.util.List.

public int

Returns:

the user drop actions.
getDropAction
()

This method returns the user drop action.

public Point

Returns:

the current Cursor location in Component's coords.
getLocation
()

This method returns a Point indicating the Cursor's current location in the Component's coordinates.

public int

Returns:

the source drop actions.
getSourceActions
()

This method returns the source drop actions.

public Transferable

Returns:

the Transferable associated with the drop
getTransferable
()

This method returns the Transferable object associated with the drop.

public boolean

Returns:

true if the DataFlavor specified is available from the source, otherwise false
isDataFlavorSupported
(DataFlavor
the DataFlavor to test
df
)

This method returns a boolean indicating if the specified DataFlavor is available from the source.

public boolean

Returns:

true if the Source is in the same JVM, otherwise false
isLocalTransfer
()

This method returns a boolean indicating if the source is in the same JVM as the target.

public void
rejectDrop()

reject the Drop.

Inherited from java.awt.dnd.DropTargetEvent:
getDropTargetContext

Field Detail

actionsback to summary
private int actions

The source drop actions.

dropActionback to summary
private int dropAction

The user drop action.

isLocalTxback to summary
private boolean isLocalTx

true if the source is in the same JVM as the target.

locationback to summary
private Point location

The location of the drag cursor's hotspot in Component coordinates.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.awt.dnd.DropTargetEvent.serialVersionUID.

Use serialVersionUID from JDK 1.4 for interoperability.

Annotations
@Serial
zeroback to summary
private static final Point zero

Constructor Detail

DropTargetDropEventback to summary
public DropTargetDropEvent(DropTargetContext dtc, Point cursorLocn, int dropAction, int srcActions)

Construct a DropTargetDropEvent given the DropTargetContext for this operation, the location of the drag Cursor's hotspot in the Component's coordinates, the currently selected user drop action, and the current set of actions supported by the source. By default, this constructor assumes that the target is not in the same virtual machine as the source; that is, isLocalTransfer() will return false.

Parameters
dtc:DropTargetContext

The DropTargetContext for this operation

cursorLocn:Point

The location of the "Drag" Cursor's hotspot in Component coordinates

dropAction:int

the user drop action.

srcActions:int

the source drop actions.

Exceptions
NullPointerException:
if cursorLocn is null
IllegalArgumentException:
  • if dropAction is not one of DnDConstants.
  • if srcActions is not a bitwise mask of DnDConstants.
  • if dtc is null.
DropTargetDropEventback to summary
public DropTargetDropEvent(DropTargetContext dtc, Point cursorLocn, int dropAction, int srcActions, boolean isLocal)

Construct a DropTargetEvent given the DropTargetContext for this operation, the location of the drag Cursor's hotspot in the Component's coordinates, the currently selected user drop action, the current set of actions supported by the source, and a boolean indicating if the source is in the same JVM as the target.

Parameters
dtc:DropTargetContext

The DropTargetContext for this operation

cursorLocn:Point

The location of the "Drag" Cursor's hotspot in Component's coordinates

dropAction:int

the user drop action.

srcActions:int

the source drop actions.

isLocal:boolean

True if the source is in the same JVM as the target

Exceptions
NullPointerException:
if cursorLocn is null
IllegalArgumentException:
  • if dropAction is not one of DnDConstants.
  • if srcActions is not a bitwise mask of DnDConstants.
  • if dtc is null.

Method Detail

acceptDropback to summary
public void acceptDrop(int dropAction)

accept the drop, using the specified action.

Parameters
dropAction:int

the specified action

dropCompleteback to summary
public void dropComplete(boolean success)

This method notifies the DragSource that the drop transfer(s) are completed.

Parameters
success:boolean

a boolean indicating that the drop transfer(s) are completed.

getCurrentDataFlavorsback to summary
public DataFlavor[] getCurrentDataFlavors()

This method returns the current DataFlavors.

Returns:DataFlavor[]

current DataFlavors

getCurrentDataFlavorsAsListback to summary
public List<DataFlavor> getCurrentDataFlavorsAsList()

This method returns the currently available DataFlavors as a java.util.List.

Returns:List<DataFlavor>

the currently available DataFlavors as a java.util.List

getDropActionback to summary
public int getDropAction()

This method returns the user drop action.

Returns:int

the user drop actions.

getLocationback to summary
public Point getLocation()

This method returns a Point indicating the Cursor's current location in the Component's coordinates.

Returns:Point

the current Cursor location in Component's coords.

getSourceActionsback to summary
public int getSourceActions()

This method returns the source drop actions.

Returns:int

the source drop actions.

getTransferableback to summary
public Transferable getTransferable()

This method returns the Transferable object associated with the drop.

Returns:Transferable

the Transferable associated with the drop

isDataFlavorSupportedback to summary
public boolean isDataFlavorSupported(DataFlavor df)

This method returns a boolean indicating if the specified DataFlavor is available from the source.

Parameters
df:DataFlavor

the DataFlavor to test

Returns:boolean

true if the DataFlavor specified is available from the source, otherwise false

isLocalTransferback to summary
public boolean isLocalTransfer()

This method returns a boolean indicating if the source is in the same JVM as the target.

Returns:boolean

true if the Source is in the same JVM, otherwise false

rejectDropback to summary
public void rejectDrop()

reject the Drop.