public class RTATextTransferHandler
extends javax.swing.TransferHandler
RTextArea
via
drag-and-drop. This class is pretty much ripped off from a subclass of
BasicTextUI
. In the future, it will include the ability to
drag-and-drop files into RTextArea
s (i.e., the text will be
inserted into the text area).The main reason this class is kept around is so we can subclass it.
构造器和说明 |
---|
RTATextTransferHandler() |
限定符和类型 | 方法和说明 |
---|---|
boolean |
canImport(javax.swing.JComponent comp,
java.awt.datatransfer.DataFlavor[] flavors)
This method indicates if a component would accept an import of the
given set of data flavors prior to actually attempting to import it.
|
protected java.awt.datatransfer.Transferable |
createTransferable(javax.swing.JComponent comp)
Create a Transferable to use as the source for a data transfer.
|
protected void |
exportDone(javax.swing.JComponent source,
java.awt.datatransfer.Transferable data,
int action)
This method is called after data has been exported.
|
protected java.awt.datatransfer.DataFlavor |
getImportFlavor(java.awt.datatransfer.DataFlavor[] flavors,
javax.swing.text.JTextComponent c)
Try to find a flavor that can be used to import a Transferable to a
specified text component.
|
int |
getSourceActions(javax.swing.JComponent c)
This is the type of transfer actions supported by the source.
|
protected void |
handleReaderImport(java.io.Reader in,
javax.swing.text.JTextComponent c)
Import the given stream data into the text component.
|
boolean |
importData(javax.swing.JComponent comp,
java.awt.datatransfer.Transferable t)
This method causes a transfer to a component from a clipboard or a
DND drop operation.
|
protected java.awt.datatransfer.DataFlavor getImportFlavor(java.awt.datatransfer.DataFlavor[] flavors, javax.swing.text.JTextComponent c)
flavors
- The flavors to check if c will accept them.c
- The text component to see whether it will accept any of the
specified data flavors as input.protected void handleReaderImport(java.io.Reader in, javax.swing.text.JTextComponent c) throws javax.swing.text.BadLocationException, java.io.IOException
javax.swing.text.BadLocationException
java.io.IOException
public int getSourceActions(javax.swing.JComponent c)
getSourceActions
在类中 javax.swing.TransferHandler
c
- The component holding the data to be transfered. This
argument is provided to enable sharing of TransferHandlers by
multiple components.protected java.awt.datatransfer.Transferable createTransferable(javax.swing.JComponent comp)
createTransferable
在类中 javax.swing.TransferHandler
comp
- The component holding the data to be transfered. This
argument is provided to enable sharing of TransferHandlers by
multiple components.protected void exportDone(javax.swing.JComponent source, java.awt.datatransfer.Transferable data, int action)
exportDone
在类中 javax.swing.TransferHandler
source
- The component that was the source of the data.data
- The data that was transferred or possibly null
if the action is NONE
.action
- The actual action that was performed.public boolean importData(javax.swing.JComponent comp, java.awt.datatransfer.Transferable t)
importData
在类中 javax.swing.TransferHandler
comp
- The component to receive the transfer. This
argument is provided to enable sharing of TransferHandlers by
multiple components.t
- The data to importtrue
iff the data was inserted into the component.public boolean canImport(javax.swing.JComponent comp, java.awt.datatransfer.DataFlavor[] flavors)
canImport
在类中 javax.swing.TransferHandler
comp
- The component to receive the transfer. This argument is
provided to enable sharing of TransferHandlers by multiple
components.flavors
- The data formats available.true
iff the data can be inserted.