Package ca.cgjennings.ui.dnd
Interface DropHandler<T>
-
- All Known Implementing Classes:
AbstractDragAndDropHandler
public interface DropHandler<T>A drop handler is responsible for responding to drops of aDragTokenonto 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 booleanacceptDrop(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.voiddragEnter(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.voiddragExit(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).voiddragMove(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.booleanhandleDrop(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 dragdragSource- the component being dragged fromtoken- the token that was draggeddropTarget- the target that the token would be dropped onlocation- the location of the potential drop- Returns:
trueif the handler would allow the drop,falseotherwise
-
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 dragdragSource- the component being dragged fromtoken- the token that was draggeddropTarget- the target that the token is being dropped onlocation- the location of the drop- Returns:
- returns
trueif the drop was successful, orfalseif 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 dragdragSource- the component being dragged fromtoken- the token that was draggeddropTarget- the target that the token is being dropped onlocation- 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 dragdragSource- the component being dragged fromtoken- the token that was draggeddropTarget- 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 dragdragSource- the component being dragged fromtoken- the token that was draggeddropTarget- the target that the token is being dropped onlocation- the location of the cursor
-
-