javax.swing.text
Class JTextComponent.DefaultTransferHandler

java.lang.Object
  extended byjavax.swing.TransferHandler
      extended byjavax.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.


Nested Class Summary
 
Nested classes inherited from class javax.swing.TransferHandler
 
Field Summary
 
Fields inherited from class javax.swing.TransferHandler
COPY, COPY_OR_MOVE, MOVE, NONE
 
Constructor Summary
(package private) JTextComponent.DefaultTransferHandler()
           
 
Method Summary
 boolean canImport(JComponent comp, DataFlavor[] transferFlavors)
          Indicates whether a component would accept an import of the given set of data flavors prior to actually attempting to import it.
 void exportToClipboard(JComponent comp, Clipboard clipboard, int action)
          Causes a transfer from the given component to the given clipboard.
private  DataFlavor getFlavor(DataFlavor[] flavors)
           
 int getSourceActions(JComponent c)
          Returns the type of transfer actions supported by the source.
 boolean importData(JComponent comp, Transferable t)
          Causes a transfer to a component from a clipboard or a DND drop operation.
 
Methods inherited from class javax.swing.TransferHandler
createTransferable, exportAsDrag, exportDone, getCopyAction, getCutAction, getPasteAction, getVisualRepresentation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JTextComponent.DefaultTransferHandler

JTextComponent.DefaultTransferHandler()
Method Detail

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 TransferHandlers by multiple components
clipboard - the clipboard to transfer the data into
action - 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 TransferHandlers by multiple components
t - 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 components
transferFlavors - 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 TransferHandlers 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)