java.awt.dnd
Class DropTargetDropEvent

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.util.EventObject sample code for java.util.EventObject definition code for java.util.EventObject 
      extended by java.awt.dnd.DropTargetEvent sample code for java.awt.dnd.DropTargetEvent definition code for java.awt.dnd.DropTargetEvent 
          extended by java.awt.dnd.DropTargetDropEvent
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable

public class DropTargetDropEvent
extends DropTargetEvent sample code for java.awt.dnd.DropTargetEvent definition code for java.awt.dnd.DropTargetEvent

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
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.awt.dnd.DropTargetEvent sample code for java.awt.dnd.DropTargetEvent definition code for java.awt.dnd.DropTargetEvent
context sample code for java.awt.dnd.DropTargetEvent.context definition code for java.awt.dnd.DropTargetEvent.context
 
Fields inherited from class java.util.EventObject sample code for java.util.EventObject definition code for java.util.EventObject
source sample code for java.util.EventObject.source definition code for java.util.EventObject.source
 
Constructor Summary
DropTargetDropEvent sample code for java.awt.dnd.DropTargetDropEvent.DropTargetDropEvent(java.awt.dnd.DropTargetContext, java.awt.Point, int, int) definition code for java.awt.dnd.DropTargetDropEvent.DropTargetDropEvent(java.awt.dnd.DropTargetContext, java.awt.Point, int, int) (DropTargetContext sample code for java.awt.dnd.DropTargetContext definition code for java.awt.dnd.DropTargetContext  dtc, Point sample code for java.awt.Point definition code for java.awt.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.
DropTargetDropEvent sample code for java.awt.dnd.DropTargetDropEvent.DropTargetDropEvent(java.awt.dnd.DropTargetContext, java.awt.Point, int, int, boolean) definition code for java.awt.dnd.DropTargetDropEvent.DropTargetDropEvent(java.awt.dnd.DropTargetContext, java.awt.Point, int, int, boolean) (DropTargetContext sample code for java.awt.dnd.DropTargetContext definition code for java.awt.dnd.DropTargetContext  dtc, Point sample code for java.awt.Point definition code for java.awt.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.
 
Method Summary
 void acceptDrop sample code for java.awt.dnd.DropTargetDropEvent.acceptDrop(int) definition code for java.awt.dnd.DropTargetDropEvent.acceptDrop(int) (int dropAction)
          accept the drop, using the specified action.
 void dropComplete sample code for java.awt.dnd.DropTargetDropEvent.dropComplete(boolean) definition code for java.awt.dnd.DropTargetDropEvent.dropComplete(boolean) (boolean success)
          This method notifies the DragSource that the drop transfer(s) are completed.
 DataFlavor sample code for java.awt.datatransfer.DataFlavor definition code for java.awt.datatransfer.DataFlavor [] getCurrentDataFlavors sample code for java.awt.dnd.DropTargetDropEvent.getCurrentDataFlavors() definition code for java.awt.dnd.DropTargetDropEvent.getCurrentDataFlavors() ()
          This method returns the current DataFlavors.
 List sample code for java.util.List definition code for java.util.List <DataFlavor sample code for java.awt.datatransfer.DataFlavor definition code for java.awt.datatransfer.DataFlavor > getCurrentDataFlavorsAsList sample code for java.awt.dnd.DropTargetDropEvent.getCurrentDataFlavorsAsList() definition code for java.awt.dnd.DropTargetDropEvent.getCurrentDataFlavorsAsList() ()
          This method returns the currently available DataFlavors as a java.util.List.
 int getDropAction sample code for java.awt.dnd.DropTargetDropEvent.getDropAction() definition code for java.awt.dnd.DropTargetDropEvent.getDropAction() ()
          This method returns the user drop action.
 Point sample code for java.awt.Point definition code for java.awt.Point getLocation sample code for java.awt.dnd.DropTargetDropEvent.getLocation() definition code for java.awt.dnd.DropTargetDropEvent.getLocation() ()
          This method returns a Point indicating the Cursor's current location in the Component's coordinates.
 int getSourceActions sample code for java.awt.dnd.DropTargetDropEvent.getSourceActions() definition code for java.awt.dnd.DropTargetDropEvent.getSourceActions() ()
          This method returns the source drop actions.
 Transferable sample code for java.awt.datatransfer.Transferable definition code for java.awt.datatransfer.Transferable getTransferable sample code for java.awt.dnd.DropTargetDropEvent.getTransferable() definition code for java.awt.dnd.DropTargetDropEvent.getTransferable() ()
          This method returns the Transferable object associated with the drop.
 boolean isDataFlavorSupported sample code for java.awt.dnd.DropTargetDropEvent.isDataFlavorSupported(java.awt.datatransfer.DataFlavor) definition code for java.awt.dnd.DropTargetDropEvent.isDataFlavorSupported(java.awt.datatransfer.DataFlavor) (DataFlavor sample code for java.awt.datatransfer.DataFlavor definition code for java.awt.datatransfer.DataFlavor  df)
          This method returns a boolean indicating if the specified DataFlavor is available from the source.
 boolean isLocalTransfer sample code for java.awt.dnd.DropTargetDropEvent.isLocalTransfer() definition code for java.awt.dnd.DropTargetDropEvent.isLocalTransfer() ()
          This method returns an int indicating if the source is in the same JVM as the target.
 void rejectDrop sample code for java.awt.dnd.DropTargetDropEvent.rejectDrop() definition code for java.awt.dnd.DropTargetDropEvent.rejectDrop() ()
          reject the Drop.
 
Methods inherited from class java.awt.dnd.DropTargetEvent sample code for java.awt.dnd.DropTargetEvent definition code for java.awt.dnd.DropTargetEvent
getDropTargetContext sample code for java.awt.dnd.DropTargetEvent.getDropTargetContext() definition code for java.awt.dnd.DropTargetEvent.getDropTargetContext()
 
Methods inherited from class java.util.EventObject sample code for java.util.EventObject definition code for java.util.EventObject
getSource sample code for java.util.EventObject.getSource() definition code for java.util.EventObject.getSource() , toString sample code for java.util.EventObject.toString() definition code for java.util.EventObject.toString()
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

DropTargetDropEvent sample code for java.awt.dnd.DropTargetDropEvent(java.awt.dnd.DropTargetContext, java.awt.Point, int, int) definition code for java.awt.dnd.DropTargetDropEvent(java.awt.dnd.DropTargetContext, java.awt.Point, int, int)

public DropTargetDropEvent(DropTargetContext sample code for java.awt.dnd.DropTargetContext definition code for java.awt.dnd.DropTargetContext  dtc,
                           Point sample code for java.awt.Point definition code for java.awt.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() sample code for java.awt.dnd.DropTargetDropEvent.isLocalTransfer() definition code for java.awt.dnd.DropTargetDropEvent.isLocalTransfer() will return false.

Parameters:
dtc - The DropTargetContext for this operation
cursorLocn - The location of the "Drag" Cursor's hotspot in Component coordinates
dropAction - the user drop action.
srcActions - the source drop actions.
Throws:
NullPointerException - if cursorLocn is null
IllegalArgumentException - if dropAction is not one of DnDConstants.
IllegalArgumentException - if srcActions is not a bitwise mask of DnDConstants.
IllegalArgumentException - if dtc is null.

DropTargetDropEvent sample code for java.awt.dnd.DropTargetDropEvent(java.awt.dnd.DropTargetContext, java.awt.Point, int, int, boolean) definition code for java.awt.dnd.DropTargetDropEvent(java.awt.dnd.DropTargetContext, java.awt.Point, int, int, boolean)

public DropTargetDropEvent(DropTargetContext sample code for java.awt.dnd.DropTargetContext definition code for java.awt.dnd.DropTargetContext  dtc,
                           Point sample code for java.awt.Point definition code for java.awt.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 - The DropTargetContext for this operation
cursorLocn - The location of the "Drag" Cursor's hotspot in Component's coordinates
dropAction - the user drop action.
srcActions - the source drop actions.
isLocal - True if the source is in the same JVM as the target
Throws:
NullPointerException - if cursorLocn is null
IllegalArgumentException - if dropAction is not one of DnDConstants.
IllegalArgumentException - if srcActions is not a bitwise mask of DnDConstants.
IllegalArgumentException - if dtc is null.
Method Detail

getLocation sample code for java.awt.dnd.DropTargetDropEvent.getLocation() definition code for java.awt.dnd.DropTargetDropEvent.getLocation()

public Point sample code for java.awt.Point definition code for java.awt.Point  getLocation()
This method returns a Point indicating the Cursor's current location in the Component's coordinates.

Returns:
the current Cursor location in Component's coords.

getCurrentDataFlavors sample code for java.awt.dnd.DropTargetDropEvent.getCurrentDataFlavors() definition code for java.awt.dnd.DropTargetDropEvent.getCurrentDataFlavors()

public DataFlavor sample code for java.awt.datatransfer.DataFlavor definition code for java.awt.datatransfer.DataFlavor [] getCurrentDataFlavors()
This method returns the current DataFlavors.

Returns:
current DataFlavors

getCurrentDataFlavorsAsList sample code for java.awt.dnd.DropTargetDropEvent.getCurrentDataFlavorsAsList() definition code for java.awt.dnd.DropTargetDropEvent.getCurrentDataFlavorsAsList()

public List sample code for java.util.List definition code for java.util.List <DataFlavor sample code for java.awt.datatransfer.DataFlavor definition code for java.awt.datatransfer.DataFlavor > getCurrentDataFlavorsAsList()
This method returns the currently available DataFlavors as a java.util.List.

Returns:
the currently available DataFlavors as a java.util.List

isDataFlavorSupported sample code for java.awt.dnd.DropTargetDropEvent.isDataFlavorSupported(java.awt.datatransfer.DataFlavor) definition code for java.awt.dnd.DropTargetDropEvent.isDataFlavorSupported(java.awt.datatransfer.DataFlavor)

public boolean isDataFlavorSupported(DataFlavor sample code for java.awt.datatransfer.DataFlavor definition code for java.awt.datatransfer.DataFlavor  df)
This method returns a boolean indicating if the specified DataFlavor is available from the source.

Parameters:
df - the DataFlavor to test

Returns:
if the DataFlavor specified is available from the source

getSourceActions sample code for java.awt.dnd.DropTargetDropEvent.getSourceActions() definition code for java.awt.dnd.DropTargetDropEvent.getSourceActions()

public int getSourceActions()
This method returns the source drop actions.

Returns:
the source drop actions.

getDropAction sample code for java.awt.dnd.DropTargetDropEvent.getDropAction() definition code for java.awt.dnd.DropTargetDropEvent.getDropAction()

public int getDropAction()
This method returns the user drop action.

Returns:
the user drop actions.

getTransferable sample code for java.awt.dnd.DropTargetDropEvent.getTransferable() definition code for java.awt.dnd.DropTargetDropEvent.getTransferable()

public Transferable sample code for java.awt.datatransfer.Transferable definition code for java.awt.datatransfer.Transferable  getTransferable()
This method returns the Transferable object associated with the drop.

Returns:
the Transferable associated with the drop

acceptDrop sample code for java.awt.dnd.DropTargetDropEvent.acceptDrop(int) definition code for java.awt.dnd.DropTargetDropEvent.acceptDrop(int)

public void acceptDrop(int dropAction)
accept the drop, using the specified action.

Parameters:
dropAction - the specified action

rejectDrop sample code for java.awt.dnd.DropTargetDropEvent.rejectDrop() definition code for java.awt.dnd.DropTargetDropEvent.rejectDrop()

public void rejectDrop()
reject the Drop.


dropComplete sample code for java.awt.dnd.DropTargetDropEvent.dropComplete(boolean) definition code for java.awt.dnd.DropTargetDropEvent.dropComplete(boolean)

public void dropComplete(boolean success)
This method notifies the DragSource that the drop transfer(s) are completed.

Parameters:
success - a boolean indicating that the drop transfer(s) are completed.

isLocalTransfer sample code for java.awt.dnd.DropTargetDropEvent.isLocalTransfer() definition code for java.awt.dnd.DropTargetDropEvent.isLocalTransfer()

public boolean isLocalTransfer()
This method returns an int indicating if the source is in the same JVM as the target.

Returns:
if the Source is in the same JVM