Class RichTextTransferHandler

  • All Implemented Interfaces:

    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:

    • pasting into the middle of a document always appends a line-feed - but it is an improvement.
    • pasting RTF DataFlavor into HTMLDocument puts weird spaces in place, and deleting those spaces isn't possible as it deletes the text instead.

    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.

    See Also:
    Serialized Form