int actions = DnDConstants.MOVE_OR_COPY;
Component component = ...;
DragHandler handler = new DragHandler(component, actions);
Icon with transparency to
represent the item being dragged (restricted to the java.awt.Window
of the drag source if the platform doesn't support drag images).
DropTargetDragEvent#acceptDrag, but often client code
simply relies on DropTargetDragEvent#getDropAction.
| Modifier and Type | Field and Description |
|---|---|
| protected static final int | COPY
Convenience to reference |
| pack-priv static final int | COPY_MASK
Modifier mask for a user-requested copy. |
| public static final float | DEFAULT_GHOST_ALPHA
Default transparency for ghosting. |
| private Component | |
| private boolean | |
| private GhostedDragImage | |
| private float | |
| private Point | |
| pack-priv static final int | KEY_MASK
Modifier mask for any user-requested action. |
| private String | |
| protected static final int | LINK
Convenience to reference |
| pack-priv static final int | LINK_MASK
Modifier mask for a user-requested link. |
| public static final Dimension | MAX_GHOST_SIZE
Default maximum size for ghosted images. |
| private Dimension | |
| private static int | |
| protected static final int | MOVE
Convenience to reference |
| pack-priv static final int | MOVE_MASK
Modifier mask for a user-requested move. |
| private boolean | |
| protected static final int | NONE
Convenience to reference |
| pack-priv static final boolean | |
| private int | |
| private static Transferable | |
| public static final int | UNKNOWN_MODIFIERS
|
| public static final Transferable | UNKNOWN_TRANSFERABLE
|
| Access | Constructor and Description |
|---|---|
| protected | DragHandler(Component dragSource, int actions)
Enable drags from the given component, supporting the actions in the given action mask. |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv static String | |
| protected int | adjustDropAction(DragSourceEvent ev)
Pick a different drop action if the target doesn't support the current one and there are no modifiers. |
| protected boolean | |
| protected Image | |
| private void | |
| private void | |
| public void | dragDropEnd(DragSourceDropEvent
the e)DragSourceDropEventImplements java. |
| public void | dragEnter(DragSourceDragEvent
the e)DragSourceDragEventImplements java. |
| public void | dragExit(DragSourceEvent
the e)DragSourceEventImplements java. |
| public void | dragGestureRecognized(DragGestureEvent
the e)DragGestureEvent describing
the gesture that has just occurredImplements java. |
| public void | dragMouseMoved(DragSourceDragEvent
the e)DragSourceDragEventImplements java. |
| public void | dragOver(DragSourceDragEvent
the e)DragSourceDragEventImplements java. |
| protected void | dragStarted(DragGestureEvent e)
Override to perform any decoration of the target at the start of a drag, if desired. |
| public void | dropActionChanged(DragSourceDragEvent
the e)DragSourceDragEventImplements java. |
| protected int | getAcceptableDropAction(int targetActions)
Returns the first available action supported by source and target. |
| protected Cursor | |
| protected Icon | getDragIcon(DragGestureEvent e, Point
set this to be the offset from the drag source
component's upper left corner to the image's upper left corner.
For example, when dragging a row from a list, the offset would be the
row's bounding rectangle's (x,y) coordinate. srcOffset)The default value is (0,0), so if unchanged, the image is will use the same origin as the drag source component. Override this to provide a custom image. |
| protected int | |
| private Point | |
| pack-priv static int | |
| public static Transferable | getTransferable(DropTargetEvent e)
Used to communicate the current |
| protected abstract Transferable | getTransferable(DragGestureEvent e)
Override to provide an appropriate |
| private int | |
| protected Icon | |
| protected void | |
| protected void |
| COPY | back to summary |
|---|---|
| protected static final int COPY Convenience to reference | |
| COPY_MASK | back to summary |
|---|---|
| pack-priv static final int COPY_MASK Modifier mask for a user-requested copy. | |
| DEFAULT_GHOST_ALPHA | back to summary |
|---|---|
| public static final float DEFAULT_GHOST_ALPHA Default transparency for ghosting. | |
| dragSource | back to summary |
|---|---|
| private Component dragSource | |
| fixCursor | back to summary |
|---|---|
| private boolean fixCursor | |
| ghost | back to summary |
|---|---|
| private GhostedDragImage ghost | |
| ghostAlpha | back to summary |
|---|---|
| private float ghostAlpha | |
| imageOffset | back to summary |
|---|---|
| private Point imageOffset | |
| KEY_MASK | back to summary |
|---|---|
| pack-priv static final int KEY_MASK Modifier mask for any user-requested action. | |
| lastAction | back to summary |
|---|---|
| private String lastAction | |
| LINK | back to summary |
|---|---|
| protected static final int LINK Convenience to reference | |
| LINK_MASK | back to summary |
|---|---|
| pack-priv static final int LINK_MASK Modifier mask for a user-requested link. | |
| MAX_GHOST_SIZE | back to summary |
|---|---|
| public static final Dimension MAX_GHOST_SIZE Default maximum size for ghosted images. | |
| maxGhostSize | back to summary |
|---|---|
| private Dimension maxGhostSize | |
| modifiers | back to summary |
|---|---|
| private static int modifiers | |
| MOVE | back to summary |
|---|---|
| protected static final int MOVE Convenience to reference | |
| MOVE_MASK | back to summary |
|---|---|
| pack-priv static final int MOVE_MASK Modifier mask for a user-requested move. | |
| moved | back to summary |
|---|---|
| private boolean moved | |
| NONE | back to summary |
|---|---|
| protected static final int NONE Convenience to reference | |
| OSX | back to summary |
|---|---|
| pack-priv static final boolean OSX | |
| supportedActions | back to summary |
|---|---|
| private int supportedActions | |
| transferable | back to summary |
|---|---|
| private static Transferable transferable | |
| UNKNOWN_MODIFIERS | back to summary |
|---|---|
| public static final int UNKNOWN_MODIFIERS
| |
| UNKNOWN_TRANSFERABLE | back to summary |
|---|---|
| public static final Transferable UNKNOWN_TRANSFERABLE
| |
| DragHandler | back to summary |
|---|---|
| protected DragHandler(Component dragSource, int actions) Enable drags from the given component, supporting the actions in the given action mask. | |
| actionString | back to summary |
|---|---|
| pack-priv static String actionString(int action) | |
| adjustDropAction | back to summary |
|---|---|
| protected int adjustDropAction(DragSourceEvent ev) Pick a different drop action if the target doesn't support the current one and there are no modifiers. | |
| canDrag | back to summary |
|---|---|
| protected boolean canDrag(DragGestureEvent e) Override to control whether a drag is started. The default implementation disallows the drag if the user is applying modifiers and the user-requested action is not supported. | |
| createDragImage | back to summary |
|---|---|
| protected Image createDragImage(GraphicsConfiguration gc, Icon icon) Create an image from the given icon. The image is provided to the native handler if drag images are supported natively. | |
| describe | back to summary |
|---|---|
| private void describe(String type, DragSourceEvent e) | |
| disableSwingDragSupport | back to summary |
|---|---|
| private void disableSwingDragSupport(Component comp) | |
| dragDropEnd | back to summary |
|---|---|
| public void dragDropEnd(DragSourceDropEvent e) Implements java. Doc from java. This method is invoked to signify that the Drag and Drop
operation is complete. The getDropSuccess() method of
the
| |
| dragEnter | back to summary |
|---|---|
| public void dragEnter(DragSourceDragEvent e) Implements java. Doc from java. Called as the cursor's hotspot enters a platform-dependent drop site. This method is invoked when all the following conditions are true:
| |
| dragExit | back to summary |
|---|---|
| public void dragExit(DragSourceEvent e) Implements java. Doc from java. Called as the cursor's hotspot exits a platform-dependent drop site. This method is invoked when any of the following conditions are true:
| |
| dragGestureRecognized | back to summary |
|---|---|
| public void dragGestureRecognized(DragGestureEvent e) Implements java. Called when a user drag gesture is recognized. This method is responsible for initiating the drag operation.
| |
| dragMouseMoved | back to summary |
|---|---|
| public void dragMouseMoved(DragSourceDragEvent e) Implements java. Doc from java. Called whenever the mouse is moved during a drag operation.
| |
| dragOver | back to summary |
|---|---|
| public void dragOver(DragSourceDragEvent e) Implements java. Doc from java. Called as the cursor's hotspot moves over a platform-dependent drop site. This method is invoked when all the following conditions are true:
| |
| dragStarted | back to summary |
|---|---|
| protected void dragStarted(DragGestureEvent e) Override to perform any decoration of the target at the start of a drag, if desired. | |
| dropActionChanged | back to summary |
|---|---|
| public void dropActionChanged(DragSourceDragEvent e) Implements java. Doc from java. Called when the user has modified the drop gesture. This method is invoked when the state of the input device(s) that the user is interacting with changes. Such devices are typically the mouse buttons or keyboard modifiers that the user is interacting with.
| |
| getAcceptableDropAction | back to summary |
|---|---|
| protected int getAcceptableDropAction(int targetActions) Returns the first available action supported by source and target. | |
| getCursorForAction | back to summary |
|---|---|
| protected Cursor getCursorForAction(int actualAction) | |
| getDragIcon | back to summary |
|---|---|
| protected Icon getDragIcon(DragGestureEvent e, Point srcOffset) Override this to provide a custom image. The
| |
| getDropAction | back to summary |
|---|---|
| protected int getDropAction(DragSourceEvent ev) Get the currently requested drop action. | |
| getImageLocation | back to summary |
|---|---|
| private Point getImageLocation(Point where) | |
| getModifiers | back to summary |
|---|---|
| pack-priv static int getModifiers() Used to communicate modifier state to | |
| getTransferable | back to summary |
|---|---|
| public static Transferable getTransferable(DropTargetEvent e) Used to communicate the current | |
| getTransferable | back to summary |
|---|---|
| protected abstract Transferable getTransferable(DragGestureEvent e) Override to provide an appropriate | |
| reduce | back to summary |
|---|---|
| private int reduce(int actions) Reduce a multiply-set bit mask to a single bit. | |
| scaleDragIcon | back to summary |
|---|---|
| protected Icon scaleDragIcon(Icon icon, Point imageOffset) Reduce the size of the given drag icon, if appropriate. When using a smaller drag icon, we also need to adjust the cursor offset within the icon. | |
| setModifiers | back to summary |
|---|---|
| protected void setModifiers(int mods) Update the modifiers hint. | |
| updateCursor | back to summary |
|---|---|
| protected void updateCursor(DragSourceEvent ev) | |