aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Copy n' Paste in JEditorPane wraps text in new css..? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Copy n Watch "Copy n New topic
Author

Copy n' Paste in JEditorPane wraps text in new css..?

Tim Quinn
Greenhorn

Joined: Sep 11, 2007
Posts: 6
Hi all,

I am writing a wysiwyg editor for html documents. I am using a JEditorPane with HTMLEditorKit.

When a user copies and pastes text, or if they highlight text and drag it, the text that they moved gets wrapped in all the css divs that were wrapping the entire document. So if I have a css border wrapping everything, copy and paste will produce three borders: a border around the top text, a border around the moved text, and a border around the bottom text.

The short self-contained example below illustrates what I mean. Try copying and pasting, or highlighting and dragging. The result is awful.

Anyone know how to gt it to copy just the text, and not all the div wrappings?

Thanks very much for any help!

Tim Quinn
Greenhorn

Joined: Sep 11, 2007
Posts: 6
(bump) Anyone have any thoughts on this?

I assume that the copy-and-paste is trying to do some clever popping out to find the furthest out html, but I wish it wouldn't try top be so clever.

I thought possibly I could overwrite to JEditorPane's actionMap, but I wasn't sure how to reliably catch the copy or paste action, especially as the same effect appears if you highlight and drag.

Any thoughts still greatly appreciated!

Tim
[ February 20, 2008: Message edited by: Tim Quinn ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Copy n' Paste in JEditorPane wraps text in new css..?