TransferHandler.TransferSupport (Java SE 15 & JDK 15) (original) (raw)

Enclosing class:

TransferHandler


public static final class TransferHandler.TransferSupport extends Object

This class encapsulates all relevant details of a clipboard or drag and drop transfer, and also allows for customizing aspects of the drag and drop experience.

The main purpose of this class is to provide the information needed by a developer to determine the suitability of a transfer or to import the data contained within. But it also doubles as a controller for customizing properties during drag and drop, such as whether or not to show the drop location, and which drop action to use.

Developers typically need not create instances of this class. Instead, they are something provided by the DnD implementation to certain methods in TransferHandler.

Since:

1.6

See Also:

TransferHandler.canImport(TransferHandler.TransferSupport), TransferHandler.importData(TransferHandler.TransferSupport)

Constructors

Constructor Description
TransferSupport​(Component component,Transferable transferable) Create a TransferSupport with isDrop() false for the given component andTransferable.
Modifier and Type Method Description
Component getComponent() Returns the target component of this transfer.
DataFlavor[] getDataFlavors() Returns the data flavors for this transfer.
int getDropAction() Returns the action chosen for the drop, when thisTransferSupport represents a drop.
TransferHandler.DropLocation getDropLocation() Returns the current (non-null) drop location for the component, when this TransferSupport represents a drop.
int getSourceDropActions() Returns the drag source's supported drop actions, when thisTransferSupport represents a drop.
Transferable getTransferable() Returns the Transferable associated with this transfer.
int getUserDropAction() Returns the user drop action for the drop, when thisTransferSupport represents a drop.
boolean isDataFlavorSupported​(DataFlavor df) Returns whether or not the given data flavor is supported.
boolean isDrop() Returns whether or not this TransferSupport represents a drop operation.
void setDropAction​(int dropAction) Sets the drop action for the transfer - which must represent a drop - to the given action, instead of the default user drop action.
void setShowDropLocation​(boolean showDropLocation) Sets whether or not the drop location should be visually indicated for the transfer - which must represent a drop.

Methods declared in class java.lang.Object

[clone](../../../java.base/java/lang/Object.html#clone%28%29), [equals](../../../java.base/java/lang/Object.html#equals%28java.lang.Object%29), [finalize](../../../java.base/java/lang/Object.html#finalize%28%29), [getClass](../../../java.base/java/lang/Object.html#getClass%28%29), [hashCode](../../../java.base/java/lang/Object.html#hashCode%28%29), [notify](../../../java.base/java/lang/Object.html#notify%28%29), [notifyAll](../../../java.base/java/lang/Object.html#notifyAll%28%29), [toString](../../../java.base/java/lang/Object.html#toString%28%29), [wait](../../../java.base/java/lang/Object.html#wait%28%29), [wait](../../../java.base/java/lang/Object.html#wait%28long%29), [wait](../../../java.base/java/lang/Object.html#wait%28long,int%29)