public class ComponentDragAndDrop extends Object
Modifier and Type | Field and Description |
---|---|
static int |
DRAG_THRESHOLD
Number of pixels traversed before a drag starts.
|
Constructor and Description |
---|
ComponentDragAndDrop(Robot robot)
Creates a new
ComponentDragAndDrop . |
Modifier and Type | Method and Description |
---|---|
void |
drag(Component target,
Point where)
Performs a drag action at the given location.
|
void |
dragOver(Component target,
Point where)
Move the mouse appropriately to get from the source to the destination.
|
void |
drop(Component target,
Point where)
Ends a drag operation, releasing the mouse button over the given target location.
|
public static final int DRAG_THRESHOLD
public ComponentDragAndDrop(@Nonnull Robot robot)
ComponentDragAndDrop
.robot
- the robot to use to simulate user input.@RunsInEDT public void drag(@Nonnull Component target, @Nonnull Point where)
target
- the target AWT or Swing Component
.where
- the point where to start the drag action.@RunsInEDT public void drop(@Nonnull Component target, @Nonnull 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()
.
target
- the target AWT or Swing Component
.where
- the point where the drag operation ends.ActionFailedException
- if there is no drag action in effect.Copyright © 2014–2019 AssertJ. All rights reserved.