Class ComponentDragAndDrop

java.lang.Object
org.fest.swing.core.ComponentDragAndDrop

public class ComponentDragAndDrop extends Object
Understands Component-based drag and drop.
Since:
1.1
  • Field Details

    • robot

      private final Robot robot
    • DRAG_THRESHOLD

      public static final int DRAG_THRESHOLD
      Number of pixels traversed before a drag starts.
  • Constructor Details

    • ComponentDragAndDrop

      public ComponentDragAndDrop(Robot robot)
      Creates a new ComponentDragAndDrop.
      Parameters:
      robot - the robot to use to simulate user input.
  • Method Details

    • drag

      @RunsInEDT public void drag(Component target, Point where)
      Performs a drag action at the given point.
      Parameters:
      target - the target component.
      where - the point where to start the drag action.
    • mouseMove

      private void mouseMove(Component target, int x, int y)
    • mouseMoveOnWindowsAndMacintosh

      @RunsInEDT private void mouseMoveOnWindowsAndMacintosh(Component target, int x, int y)
    • distance

      private int distance(int coordinate, int dimension)
    • point

      private Point point(int x, int y)
    • drop

      @RunsInEDT public void drop(Component target, Point where)
      Ends a drag operation, releasing the mouse button over the given target location.

      This method is tuned for native drag/drop operations, so if you get odd behavior, you might try using a simple Robot.moveMouse(Component, int, int) and Robot.releaseMouseButtons().

      Parameters:
      target - the target component.
      where - the point where the drag operation ends.
      Throws:
      ActionFailedException - if there is no drag action in effect.
    • delayBetweenEvents

      private int delayBetweenEvents()
    • settings

      private Settings settings()
    • dragOver

      public void dragOver(Component target, Point where)
      Move the mouse appropriately to get from the source to the destination. Enter/exit events will be generated where appropriate.
      Parameters:
      target - the target component.
      where - the point to drag over.
    • dragOver

      private void dragOver(Component target, int x, int y)
    • mouseMove

      private void mouseMove(Component target, Point... points)