Interface DropHandler<T>

  • All Known Implementing Classes:
    AbstractDragAndDropHandler

    public interface DropHandler<T>
    A drop handler is responsible for responding to drops of a DragToken onto a drop target. It acts as the bridge between a UI component that can act as a drop target and the drag token framework.
    Since:
    3.0
    Author:
    Chris Jennings
    See Also:
    DragHandler, DragManager
    • Method Summary

      All Methods Instance Methods Abstract 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 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.
      boolean handleDrop​(DragManager<T> manager, javax.swing.JComponent dragSource, DragToken<T> token, javax.swing.JComponent dropTarget, java.awt.Point location)
      Called when a drag gesture finishes with a drop.
    • Method Detail

      • acceptDrop

        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.
        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
      • handleDrop

        boolean handleDrop​(DragManager<T> manager,
                           javax.swing.JComponent dragSource,
                           DragToken<T> token,
                           javax.swing.JComponent dropTarget,
                           java.awt.Point location)
        Called when a drag gesture finishes with a drop. The handler should take whatever action is necessary to complete the action. Typically this means adding the content of the token to the container represented by the drop target.
        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 drop
        Returns:
        returns true if the drop was successful, or false if it could not be completed
      • dragEnter

        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. This can be used to update the visual representation of the target.
        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

        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). This can be used to update the visual representation of the target.
        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

        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. This can be used to update the visual representation of the target.
        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