Package docking.dnd
Class DropTgtAdapter
- java.lang.Object
-
- docking.dnd.DropTgtAdapter
-
- All Implemented Interfaces:
java.awt.dnd.DropTargetListener
,java.util.EventListener
public class DropTgtAdapter extends java.lang.Object implements java.awt.dnd.DropTargetListener
Class to handle notifications of drag and drop operations that occur on the DropTarget object. The DropTarget is the component that accepts drops during a drag and drop operation. The drop method actually transfers the data.
-
-
Constructor Summary
Constructors Constructor Description DropTgtAdapter(Droppable dropComponent, int acceptableDropActions, java.awt.datatransfer.DataFlavor[] acceptableDropFlavors)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dragEnter(java.awt.dnd.DropTargetDragEvent e)
DropTargetListener method called when the drag operation encounters the drop target.void
dragExit(java.awt.dnd.DropTargetEvent e)
DropTargetListener method called when the drag operation exits the drop target without dropping.void
dragOver(java.awt.dnd.DropTargetDragEvent e)
DropTargetListener method called when the drag operation is over the drop target.void
drop(java.awt.dnd.DropTargetDropEvent e)
DropTargetListener method called when the drag operation terminates and drops onto the drop target.void
dropActionChanged(java.awt.dnd.DropTargetDragEvent e)
DropTargetListener method called when the user modifies the drag action.static java.awt.datatransfer.DataFlavor[]
getAllMatchingFlavors(java.awt.dnd.DropTargetDragEvent e, java.awt.datatransfer.DataFlavor[] acceptableFlavors)
static java.awt.datatransfer.DataFlavor
getFirstMatchingFlavor(java.awt.dnd.DropTargetDragEvent e, java.awt.datatransfer.DataFlavor[] acceptableFlavors)
protected boolean
isDragFlavorSupported(java.awt.dnd.DropTargetDragEvent e)
Returns true if the drop target can accept the data flavor that is to be dropped.protected boolean
isDropOk(java.awt.dnd.DropTargetDragEvent e)
Returns true if the drop operation is OK.void
setAcceptableDropFlavors(java.awt.datatransfer.DataFlavor[] dropFlavors)
Set the data flavors acceptable to the associated drop target.
-
-
-
Constructor Detail
-
DropTgtAdapter
public DropTgtAdapter(Droppable dropComponent, int acceptableDropActions, java.awt.datatransfer.DataFlavor[] acceptableDropFlavors)
Constructor- Parameters:
dropComponent
- the drop targetacceptableDropActions
- a DnDConstants variable that defines dnd actionsacceptableDropFlavors
- acceptable data formats that the drop target can handle
-
-
Method Detail
-
setAcceptableDropFlavors
public void setAcceptableDropFlavors(java.awt.datatransfer.DataFlavor[] dropFlavors)
Set the data flavors acceptable to the associated drop target.- Parameters:
dropFlavors
-
-
dragEnter
public void dragEnter(java.awt.dnd.DropTargetDragEvent e)
DropTargetListener method called when the drag operation encounters the drop target.- Specified by:
dragEnter
in interfacejava.awt.dnd.DropTargetListener
- Parameters:
e
- event that has current state of drag and drop operation
-
dragOver
public void dragOver(java.awt.dnd.DropTargetDragEvent e)
DropTargetListener method called when the drag operation is over the drop target.- Specified by:
dragOver
in interfacejava.awt.dnd.DropTargetListener
- Parameters:
e
- event that has current state of drag and drop operation
-
dragExit
public void dragExit(java.awt.dnd.DropTargetEvent e)
DropTargetListener method called when the drag operation exits the drop target without dropping. However, this method is also called even when the drop completes.- Specified by:
dragExit
in interfacejava.awt.dnd.DropTargetListener
- Parameters:
e
- event that has current state of drag and drop operation
-
dropActionChanged
public void dropActionChanged(java.awt.dnd.DropTargetDragEvent e)
DropTargetListener method called when the user modifies the drag action.- Specified by:
dropActionChanged
in interfacejava.awt.dnd.DropTargetListener
- Parameters:
e
- event that has current state of drag and drop operation
-
drop
public void drop(java.awt.dnd.DropTargetDropEvent e)
DropTargetListener method called when the drag operation terminates and drops onto the drop target.- Specified by:
drop
in interfacejava.awt.dnd.DropTargetListener
- Parameters:
e
- event that has current state of drag and drop operation
-
isDropOk
protected boolean isDropOk(java.awt.dnd.DropTargetDragEvent e)
Returns true if the drop operation is OK. A drop is deemed to be okay if
1. the drop target accepts one of the data flavors that the event's transferrable provides.
2. the drop action (i.e. COPY, MOVE, etc.) is accepted by the target.
3. the drop is accepted by the Droppable component.- Parameters:
e
- event that has current state of drag and drop operation
-
isDragFlavorSupported
protected boolean isDragFlavorSupported(java.awt.dnd.DropTargetDragEvent e)
Returns true if the drop target can accept the data flavor that is to be dropped.
-
getFirstMatchingFlavor
public static java.awt.datatransfer.DataFlavor getFirstMatchingFlavor(java.awt.dnd.DropTargetDragEvent e, java.awt.datatransfer.DataFlavor[] acceptableFlavors)
-
getAllMatchingFlavors
public static java.awt.datatransfer.DataFlavor[] getAllMatchingFlavors(java.awt.dnd.DropTargetDragEvent e, java.awt.datatransfer.DataFlavor[] acceptableFlavors)
-
-