Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / February 2005

Tip: Looking for answers? Try searching our database.

RTFEditorKit vs. clipboard: formats

Thread view: 
Fred Nurke - 24 Feb 2005 19:41 GMT
Hi folks,

I'm using an RTFEditorKit in a JTextPane.  I'd like to copy the RTF
text from the text pane to the (Windows) clipboard, but calling
JTextPane's copy() method only copies plain text.  If I use an
HTMLEditorKit, the same call gives me HTML on the clipboard, so I think
my code's doing what it should.

Is this a bug in the RTFEditorKit?  Will it ever be fixed?

If it is a bug, how do I go about fixing it?  I gather I need to
implement a new TransferHandler, but I don't know how to do that or
where to go for more information.

Thanks!

Fred
Thomas Weidenfeller - 25 Feb 2005 08:16 GMT
> I'm using an RTFEditorKit in a JTextPane.  I'd like to copy the RTF
> text from the text pane to the (Windows) clipboard, but calling
[quoted text clipped - 3 lines]
>
> Is this a bug in the RTFEditorKit?

Probably, I don't know for sure. I know that the Styled document doesn't
implement a proper way to get styled text back, so this might be the
root of your problem. See
http://groups.google.com/groups?threadm=1108628560.718458.178640%40l41g2000cwc.g
ooglegroups.com

for a related discussion.

Also, check Sun's bug parade to find out if this is a known bug.

> Will it ever be fixed?

Most likely not. RTF (and HTML) editing don't have any attention from Sun.

> If it is a bug, how do I go about fixing it?

You could try to work around it by drilling down to the document, and
trying to write some own extraction method for the current selection.
You could then try to manually copy that DataFlavor to the clipboard
(see the java.awt.datatransfer package) or via a custom TransferHandler.

> I gather I need to
> implement a new TransferHandler, but I don't know how to do that or
> where to go for more information.

TransferHandler is just a front end to the java.awt.datatransfer
package. Have a look at the documentation for that package to understand
the basics. Then check
http://java.sun.com/docs/books/tutorial/uiswing/misc/dnd.html

/Thomas
Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.