javax.swing
Class TransferHandler.TransferInfo

java.lang.Object
  extended by javax.swing.TransferHandler.TransferInfo
Enclosing class:
TransferHandler

public static final class TransferHandler.TransferInfo
extends Object

This class tracks and provides the information needed to decide whether or not and how to import data.

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.TransferInfo), TransferHandler.importData(TransferHandler.TransferInfo)

Constructor Summary
TransferHandler.TransferInfo(Component component, Transferable transferable)
          Create a TransferInfo with isDrop() false for the given component and Transferable.
 
Method Summary
 Component getComponent()
          Returns the target component of this transfer.
 DataFlavor[] getDataFlavors()
          Return the data flavors for this transfer.
 TransferHandler.DropLocation getDropLocation()
          If this is a drop, return the current drop location for this component.
 Transferable getTransferable()
          Returns the Transferable associated with this transfer.
 boolean isDataFlavorSupported(DataFlavor df)
          Returns whether or not the given data flavor is supported.
 boolean isDrop()
          Returns whether or not this TransferInfo represents a drop operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransferHandler.TransferInfo

public TransferHandler.TransferInfo(Component component,
                                    Transferable transferable)
Create a TransferInfo with isDrop() false for the given component and Transferable.

Parameters:
component - the target component
transferable - the transferable
Throws:
NullPointerException - if either parameter is null
Method Detail

isDrop

public boolean isDrop()
Returns whether or not this TransferInfo represents a drop operation.

Returns:
true if this is a drop operation, false otherwise.

getComponent

public Component getComponent()
Returns the target component of this transfer.

Returns:
the target component

getDropLocation

public TransferHandler.DropLocation getDropLocation()
If this is a drop, return the current drop location for this component. If this is not a drop, returns null.

Note: For components with built-in drop support, this location will be a subclass of DropLocation of the same type returned by that component's getDropLocation method.

Returns:
the drop location, or null

getDataFlavors

public DataFlavor[] getDataFlavors()
Return the data flavors for this transfer.

Returns:
the data flavors for this transfer

isDataFlavorSupported

public boolean isDataFlavorSupported(DataFlavor df)
Returns whether or not the given data flavor is supported.

Parameters:
df - the DataFlavor to test
Returns:
whether or not the given flavor is supported.

getTransferable

public Transferable getTransferable()
Returns the Transferable associated with this transfer.

Note: Unless it is necessary to fetch the Transferable directly, use one of the other methods on this class to inquire about the transfer. This may perform better than fetching the Transferable and asking it directly.

Returns:
the Transferable associated with this transfer