TransferHandler (Java SE 19 & JDK 19) (original) (raw)

All Implemented Interfaces:

[Serializable](../../../java.base/java/io/Serializable.html "interface in java.io")


This class is used to handle the transfer of a Transferable to and from Swing components. The Transferable is used to represent data that is exchanged via a cut, copy, or paste to/from a clipboard. It is also used in drag-and-drop operations to represent a drag from a component, and a drop to a component. Swing provides functionality that automatically supports cut, copy, and paste keyboard bindings that use the functionality provided by an implementation of this class. Swing also provides functionality that automatically supports drag and drop that uses the functionality provided by an implementation of this class. The Swing developer can concentrate on specifying the semantics of a transfer primarily by setting the transferHandler property on a Swing component.

This class is implemented to provide a default behavior of transferring a component property simply by specifying the name of the property in the constructor. For example, to transfer the foreground color from one component to another either via the clipboard or a drag and drop operation a TransferHandler can be constructed with the string "foreground". The built in support will use the color returned by getForeground as the source of the transfer, and setForeground for the target of a transfer.

Please see How to Use Drag and Drop and Data Transfer, a section in The Java Tutorial, for more information.

Since:

1.4

Nested Classes
static class
Represents a location where dropped data should be inserted.
static final class
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.

Fields
static final int
An int representing a "copy" transfer action.
static final int
An int representing a source action capability of either "copy" or "move".
static final int
An int representing a "link" transfer action.
static final int
An int representing a "move" transfer action.
static final int
An int representing no transfer action.

Constructors
protected
Convenience constructor for subclasses.
Constructs a transfer handler that can transfer a Java Bean property from one component to another via the clipboard or a drag and drop operation.

boolean
Indicates whether a component will accept an import of the given set of data flavors prior to actually attempting to import it.
boolean
This method is called repeatedly during a drag and drop operation to allow the developer to configure properties of, and to return the acceptability of transfers; with a return value of true indicating that the transfer represented by the givenTransferSupport (which contains all of the details of the transfer) is acceptable at the current time, and a value of false rejecting the transfer.
Creates a Transferable to use as the source for a data transfer.
void
Causes the Swing drag support to be initiated.
protected void
Invoked after data has been exported.
void
Causes a transfer from the given component to the given clipboard.
Returns an Action that performs copy operations to the clipboard.
Returns an Action that performs cut operations to the clipboard.
Returns an anchor offset for the image to drag.
Returns an Action that performs paste operations from the clipboard.
int
Returns the type of transfer actions supported by the source; any bitwise-OR combination of COPY, MOVE and LINK.
Returns an object that establishes the look of a transfer.
boolean
Causes a transfer to a component from a clipboard or a DND drop operation.
boolean
Causes a transfer to occur from a clipboard or a drag and drop operation.
void
Sets the drag image parameter.
void
Sets an anchor offset for the image to drag.

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)