Class AbstractDragAndDropHandler<T>

  • All Implemented Interfaces:
    DragHandler<T>, DropHandler<T>

    public abstract class AbstractDragAndDropHandler<T>
    extends java.lang.Object
    implements DragHandler<T>, DropHandler<T>
    An abstract base class that combines a DragHandler and a DropHandler in a single object. This can be a useful basis for building interactions with reasonably simple drag logic, such as dragging and dropping between two containers. For convenience, the method acceptDrop returns true; the methods dragFinished, dragEnter, dragExit, and dragMove have empty implementations.
    Since:
    3.0
    Author:
    Chris Jennings
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean acceptDrop​(DragManager<T> manager, javax.swing.JComponent dragSource, DragToken<T> token, javax.swing.JComponent dropTarget, java.awt.Point location)
      Called to determine if a drop target is willing to accept a particular drop.
      void dragEnter​(DragManager<T> manager, javax.swing.JComponent dragSource, DragToken<T> token, javax.swing.JComponent dropTarget, java.awt.Point location)
      Called when the cursor enters a viable drop target.
      void dragExit​(DragManager<T> manager, javax.swing.JComponent dragSource, DragToken<T> token, javax.swing.JComponent dropTarget)
      Called when the cursor leaves a drop target (or moves over part of the target that will not accept the drop).
      void dragFinished​(DragManager<T> manager, javax.swing.JComponent dragSource, DragToken<T> token, javax.swing.JComponent dropTarget)
      Called when a drag gesture finishes, whether the drag token was successfully dropped or not.
      void dragMove​(DragManager<T> manager, javax.swing.JComponent dragSource, DragToken<T> token, javax.swing.JComponent dropTarget, java.awt.Point location)
      Called when the cursor is moved over a viable drop target.
      • Methods inherited from class java.lang.Object

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

      • AbstractDragAndDropHandler

        public AbstractDragAndDropHandler()
    • Method Detail

      • acceptDrop

        public boolean acceptDrop​(DragManager<T> manager,
                                  javax.swing.JComponent dragSource,
                                  DragToken<T> token,
                                  javax.swing.JComponent dropTarget,
                                  java.awt.Point location)
        Description copied from interface: DropHandler
        Called to determine if a drop target is willing to accept a particular drop.
        Specified by:
        acceptDrop in interface DropHandler<T>
        Parameters:
        manager - the manager that is managing the drag
        dragSource - the component being dragged from
        token - the token that was dragged
        dropTarget - the target that the token would be dropped on
        location - the location of the potential drop
        Returns:
        true if the handler would allow the drop, false otherwise
      • dragFinished

        public void dragFinished​(DragManager<T> manager,
                                 javax.swing.JComponent dragSource,
                                 DragToken<T> token,
                                 javax.swing.JComponent dropTarget)
        Description copied from interface: DragHandler
        Called when a drag gesture finishes, whether the drag token was successfully dropped or not. This method is called after
        Specified by:
        dragFinished in interface DragHandler<T>
        Parameters:
        manager - the manager that is managing the drag
        dragSource - the component being dragged from
        token - the token that was dragged
        dropTarget - the target that the token was dropped on, or null if the drag was cancelled
      • dragEnter

        public void dragEnter​(DragManager<T> manager,
                              javax.swing.JComponent dragSource,
                              DragToken<T> token,
                              javax.swing.JComponent dropTarget,
                              java.awt.Point location)
        Description copied from interface: DropHandler
        Called when the cursor enters a viable drop target. This can be used to update the visual representation of the target.
        Specified by:
        dragEnter in interface DropHandler<T>
        Parameters:
        manager - the manager that is managing the drag
        dragSource - the component being dragged from
        token - the token that was dragged
        dropTarget - the target that the token is being dropped on
        location - the location of the cursor
      • dragExit

        public void dragExit​(DragManager<T> manager,
                             javax.swing.JComponent dragSource,
                             DragToken<T> token,
                             javax.swing.JComponent dropTarget)
        Description copied from interface: DropHandler
        Called when the cursor leaves a drop target (or moves over part of the target that will not accept the drop). This can be used to update the visual representation of the target.
        Specified by:
        dragExit in interface DropHandler<T>
        Parameters:
        manager - the manager that is managing the drag
        dragSource - the component being dragged from
        token - the token that was dragged
        dropTarget - the target that the token is being dropped on
      • dragMove

        public void dragMove​(DragManager<T> manager,
                             javax.swing.JComponent dragSource,
                             DragToken<T> token,
                             javax.swing.JComponent dropTarget,
                             java.awt.Point location)
        Description copied from interface: DropHandler
        Called when the cursor is moved over a viable drop target. This can be used to update the visual representation of the target.
        Specified by:
        dragMove in interface DropHandler<T>
        Parameters:
        manager - the manager that is managing the drag
        dragSource - the component being dragged from
        token - the token that was dragged
        dropTarget - the target that the token is being dropped on
        location - the location of the cursor