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. Thedrop
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)
void
dragExit(java.awt.dnd.DropTargetEvent e)
void
dragOver(java.awt.dnd.DropTargetDragEvent e)
void
drop(java.awt.dnd.DropTargetDropEvent e)
void
dropActionChanged(java.awt.dnd.DropTargetDragEvent e)
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 droppedprotected 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
- the flavors
-
dragEnter
public void dragEnter(java.awt.dnd.DropTargetDragEvent e)
- Specified by:
dragEnter
in interfacejava.awt.dnd.DropTargetListener
-
dragOver
public void dragOver(java.awt.dnd.DropTargetDragEvent e)
- Specified by:
dragOver
in interfacejava.awt.dnd.DropTargetListener
-
dragExit
public void dragExit(java.awt.dnd.DropTargetEvent e)
- Specified by:
dragExit
in interfacejava.awt.dnd.DropTargetListener
-
dropActionChanged
public void dropActionChanged(java.awt.dnd.DropTargetDragEvent e)
- Specified by:
dropActionChanged
in interfacejava.awt.dnd.DropTargetListener
-
drop
public void drop(java.awt.dnd.DropTargetDropEvent e)
- Specified by:
drop
in interfacejava.awt.dnd.DropTargetListener
-
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- the drop target accepts one of the data flavors that the event's transferable provides
- the drop action (i.e. COPY, MOVE, etc.) is accepted by the target
- the drop is accepted by the Droppable component
- Parameters:
e
- event that has current state of drag and drop operation- Returns:
- true if the drop operation is OK
-
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- Parameters:
e
- event that has current state of drag and drop operation- 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)
-
-