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

T

tk

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,237
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top