In Swing, using the RTFEditorKit, how to copy/cut Formatting *and* text to the Clipboard?

Discussion in 'Java' started by tk, Jul 26, 2003.

  1. tk

    tk Guest

    Hi Folks:

    Any idea on the best approach to support copy/cut of all style/formatting as
    well as plain text for a JTextPane? I googled quite a bit and located a
    word processing program that supports JTextPane but they specifically
    mention it only places "plain text" to the Clipboard and ignores the
    formatting information when transfering.

    I was thinking about implementing the Transferable interface and using the
    Clipboard.setContents(..) method but I'm not sure yet by which procedure I
    implement the getTransferData() as it wants to return an Object. I could
    use a byte[] stream and return a ByteArrayOutputStream who's contents would
    be filled with the Document's data (ie, plain text *and* the control/style
    information). I just don't know if that would work yet but I plan to try
    that.

    Seems like there's very little (if anything) mentioned in the sun
    developer's forum on how to do this as well as in google...

    First of all, is Java's support for RTF still somewhat "primative"??? I
    have a full blown word processor going which looks like Word and supports
    font changes, size changes, find/replace operations, etc... It's just that
    the cut/copy only transfers the plain text (despite my attempts to call
    setContentType("text/rtf")) to the clipboard and not the style information.

    thanks for any insight, Theron
    tk, Jul 26, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stephen Boulet

    Cut and paste to X clipboard?

    Stephen Boulet, Jun 25, 2004, in forum: Python
    Replies:
    3
    Views:
    522
    Stephen Boulet
    Jun 29, 2004
  2. Ranjith

    Using RTFEditorKit

    Ranjith, Jan 10, 2010, in forum: Java
    Replies:
    1
    Views:
    2,101
    Roedy Green
    Jan 10, 2010
  3. Mahsha

    Clipboard - Copy Image To Clipboard

    Mahsha, Jun 1, 2009, in forum: Javascript
    Replies:
    1
    Views:
    556
    Thomas 'PointedEars' Lahn
    Jun 1, 2009
  4. Mahsha

    Clipboard - Copy Text To Clipboard

    Mahsha, Jun 1, 2009, in forum: Javascript
    Replies:
    3
    Views:
    624
    Thomas 'PointedEars' Lahn
    Jun 1, 2009
  5. Mahsha
    Replies:
    2
    Views:
    2,058
    Gregor Kofler
    Jun 4, 2009
Loading...

Share This Page