Interface PaletteDragSupport.PaletteDragSource

Enclosing class:
PaletteDragSupport
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public static interface PaletteDragSupport.PaletteDragSource
Supplies the drag payload and receives end-of-drag notification.

Implement this interface (typically as a lambda) and pass it to the PaletteDragSupport constructor. The two methods correspond to the two moments the palette cares about: "what are we dragging?" and "the drag is over, clean up".

  • Method Summary

    Modifier and Type
    Method
    Description
    Return the Transferable payload for a drag starting at dragOrigin, or null to cancel the drag.
    default void
    Called on the EDT after every drag attempt ends — success, failure, or cancellation.
  • Method Details

    • createTransferable

      Transferable createTransferable(Point dragOrigin)
      Return the Transferable payload for a drag starting at dragOrigin, or null to cancel the drag.

      Called on the EDT from the DragSource gesture recogniser. Returning null suppresses the drag entirely — no cursor change, no drop target notification. This is the correct way to reject a drag that starts on a non-draggable area (e.g. a label column in a table).

      Parameters:
      dragOrigin - the point, in the source component's coordinate space, where the drag gesture began
      Returns:
      the payload to carry, or null to cancel
    • onDragEnd

      default void onDragEnd()
      Called on the EDT after every drag attempt ends — success, failure, or cancellation.

      The default implementation is a no-op. Override to clear a selection highlight or reset any transient visual state.