Package docking.dnd

Class 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)  
      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 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DropTgtAdapter

        public DropTgtAdapter​(Droppable dropComponent,
                              int acceptableDropActions,
                              java.awt.datatransfer.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 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 interface java.awt.dnd.DropTargetListener
      • dragOver

        public void dragOver​(java.awt.dnd.DropTargetDragEvent e)
        Specified by:
        dragOver in interface java.awt.dnd.DropTargetListener
      • dragExit

        public void dragExit​(java.awt.dnd.DropTargetEvent e)
        Specified by:
        dragExit in interface java.awt.dnd.DropTargetListener
      • dropActionChanged

        public void dropActionChanged​(java.awt.dnd.DropTargetDragEvent e)
        Specified by:
        dropActionChanged in interface java.awt.dnd.DropTargetListener
      • drop

        public void drop​(java.awt.dnd.DropTargetDropEvent e)
        Specified by:
        drop in interface java.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
        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​(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)