Package docking.dnd
Class DropTgtAdapter
java.lang.Object
docking.dnd.DropTgtAdapter
- All Implemented Interfaces:
DropTargetListener
,EventListener
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
ConstructorDescriptionDropTgtAdapter
(Droppable dropComponent, int acceptableDropActions, DataFlavor[] acceptableDropFlavors) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
void
void
void
static DataFlavor
getFirstMatchingFlavor
(DropTargetDragEvent e, DataFlavor[] acceptableFlavors) protected boolean
Returns true if the drop target can accept the data flavor that is to be droppedprotected boolean
Returns true if the drop operation is OK.void
setAcceptableDropFlavors
(DataFlavor[] dropFlavors) Set the data flavors acceptable to the associated drop target
-
Constructor Details
-
DropTgtAdapter
public DropTgtAdapter(Droppable dropComponent, int acceptableDropActions, 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 Details
-
setAcceptableDropFlavors
Set the data flavors acceptable to the associated drop target- Parameters:
dropFlavors
- the flavors
-
dragEnter
- Specified by:
dragEnter
in interfaceDropTargetListener
-
dragOver
- Specified by:
dragOver
in interfaceDropTargetListener
-
dragExit
- Specified by:
dragExit
in interfaceDropTargetListener
-
dropActionChanged
- Specified by:
dropActionChanged
in interfaceDropTargetListener
-
drop
- Specified by:
drop
in interfaceDropTargetListener
-
isDropOk
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
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 DataFlavor getFirstMatchingFlavor(DropTargetDragEvent e, DataFlavor[] acceptableFlavors)
-