Package docking.dnd

Class DropTgtAdapter

java.lang.Object
docking.dnd.DropTgtAdapter
All Implemented Interfaces:
DropTargetListener, EventListener

public class DropTgtAdapter extends Object implements 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 Details

    • DropTgtAdapter

      public DropTgtAdapter(Droppable dropComponent, int acceptableDropActions, DataFlavor[] acceptableDropFlavors)
      Constructor
      Parameters:
      dropComponent - the drop target
      acceptableDropActions - a DnDConstants variable that defines dnd actions
      acceptableDropFlavors - acceptable data formats that the drop target can handle
  • Method Details

    • setAcceptableDropFlavors

      public void setAcceptableDropFlavors(DataFlavor[] dropFlavors)
      Set the data flavors acceptable to the associated drop target
      Parameters:
      dropFlavors - the flavors
    • dragEnter

      public void dragEnter(DropTargetDragEvent e)
      Specified by:
      dragEnter in interface DropTargetListener
    • dragOver

      public void dragOver(DropTargetDragEvent e)
      Specified by:
      dragOver in interface DropTargetListener
    • dragExit

      public void dragExit(DropTargetEvent e)
      Specified by:
      dragExit in interface DropTargetListener
    • dropActionChanged

      public void dropActionChanged(DropTargetDragEvent e)
      Specified by:
      dropActionChanged in interface DropTargetListener
    • drop

      public void drop(DropTargetDropEvent e)
      Specified by:
      drop in interface DropTargetListener
    • isDropOk

      protected boolean isDropOk(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 transferable 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
      Returns:
      true if the drop operation is OK
    • isDragFlavorSupported

      protected boolean isDragFlavorSupported(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 DataFlavor getFirstMatchingFlavor(DropTargetDragEvent e, DataFlavor[] acceptableFlavors)