public class RichTextTransferHandler extends TransferHandler
A TransferHandler
that can copy/paste RichText. The default TransferHandler
on a JEditorPane can't copy RichText, and pasting it will insert it at the
end of the document rather than at the caret (because RTFEditorKit ignores
the "pos" attribute in read).
This isn't a perfect solution - in particular the following faults exist:
Tested on Windows and OS X for copying/pasting between plain, RTF and HTML JEditorPanes with or without the handler, and also testing paste in from and copy out to external application.
Also works with TextTool to allow copying of styled text.
Modifier and Type | Class and Description |
---|---|
static class |
RichTextTransferHandler.RichTransferable
Transferable class that can transfer Rich-Text as plain, RTF or HTML.
|
TransferHandler.DropLocation, TransferHandler.TransferSupport
COPY, COPY_OR_MOVE, LINK, MOVE, NONE
Constructor and Description |
---|
RichTextTransferHandler() |
Modifier and Type | Method and Description |
---|---|
boolean |
canImport(JComponent c,
DataFlavor[] f) |
protected Transferable |
createTransferable(JComponent c) |
int |
getSourceActions(JComponent c) |
boolean |
importData(JComponent c,
Transferable tran) |
canImport, exportAsDrag, exportDone, exportToClipboard, getCopyAction, getCutAction, getDragImage, getDragImageOffset, getPasteAction, getVisualRepresentation, importData, setDragImage, setDragImageOffset
public boolean canImport(JComponent c, DataFlavor[] f)
canImport
in class TransferHandler
public boolean importData(JComponent c, Transferable tran)
importData
in class TransferHandler
protected Transferable createTransferable(JComponent c)
createTransferable
in class TransferHandler
public int getSourceActions(JComponent c)
getSourceActions
in class TransferHandler
Copyright © 2001-2017 Big Faceless Organization