javax.swing.text
Class JTextComponent.DefaultTransferHandler
java.lang.Object
javax.swing.TransferHandler
javax.swing.text.JTextComponent.DefaultTransferHandler
- All Implemented Interfaces:
- Serializable, UIResource
- Enclosing class:
- JTextComponent
- static class JTextComponent.DefaultTransferHandler
- extends TransferHandler
- implements UIResource
A Simple TransferHandler that exports the data as a String, and
imports the data from the String clipboard. This is only used
if the UI hasn't supplied one, which would only happen if someone
hasn't subclassed Basic.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JTextComponent.DefaultTransferHandler
JTextComponent.DefaultTransferHandler()
exportToClipboard
public void exportToClipboard(JComponent comp,
Clipboard clipboard,
int action)
- Description copied from class:
TransferHandler
- Causes a transfer from the given component to the
given clipboard. This method is called by the default cut and
copy actions registered in a component's action map.
The transfer will have been completed at the
return of this call. The transfer will take place using the
java.awt.datatransfer
mechanism,
requiring no further effort from the developer.
The exportDone
method will be called when the
transfer has completed.
- Overrides:
exportToClipboard
in class TransferHandler
- Parameters:
comp
- the component holding the data to be transferred; this
argument is provided to enable sharing of TransferHandler
s by
multiple componentsclipboard
- the clipboard to transfer the data intoaction
- the transfer action requested; this should
be a value of either COPY
or MOVE
;
the operation performed is the intersection of the transfer
capabilities given by getSourceActions and the requested action;
the intersection may result in an action of NONE
if the requested action isn't supported
importData
public boolean importData(JComponent comp,
Transferable t)
- Description copied from class:
TransferHandler
- Causes a transfer to a component from a clipboard or a
DND drop operation. The
Transferable
represents
the data to be imported into the component.
- Overrides:
importData
in class TransferHandler
- Parameters:
comp
- the component to receive the transfer; this
argument is provided to enable sharing of TransferHandler
s
by multiple componentst
- the data to import
- Returns:
- true if the data was inserted into the component, false otherwise
canImport
public boolean canImport(JComponent comp,
DataFlavor[] transferFlavors)
- Description copied from class:
TransferHandler
- Indicates whether a component would accept an import of the given
set of data flavors prior to actually attempting to import it.
- Overrides:
canImport
in class TransferHandler
- Parameters:
comp
- the component to receive the transfer; this
argument is provided to enable sharing of TransferHandlers
by multiple componentstransferFlavors
- the data formats available
- Returns:
- true if the data can be inserted into the component, false otherwise
getSourceActions
public int getSourceActions(JComponent c)
- Description copied from class:
TransferHandler
- Returns the type of transfer actions supported by the source.
Some models are not mutable, so a transfer operation of
COPY
only should be advertised in that case.
- Overrides:
getSourceActions
in class TransferHandler
- Parameters:
c
- the component holding the data to be transferred; this
argument is provided to enable sharing of TransferHandler
s
by multiple components.
- Returns:
COPY
if the transfer property can be found,
otherwise returns NONE
; a return value of
of NONE
disables any transfers out of the component
getFlavor
private DataFlavor getFlavor(DataFlavor[] flavors)