Results 1 to 1 of 1
- 02-06-2008, 03:55 PM #1
Member
- Join Date
- Feb 2008
- Posts
- 1
- Rep Power
- 0
Copy n' Paste in JEditorPane wraps text in new css..?
Click to email this message Click to edit this message...
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!
Sam
Java Code:import javax.swing.*; import javax.swing.text.html.*; public class SwingTester extends JFrame { public SwingTester() { JEditorPane editorPane = new JEditorPane(); editorPane.setEditorKit(new HTMLEditorKit()); editorPane.setEditable(true); String html = "<div style=\"background-color: green; padding: 5px\">" + "<div style=\"background-color: white;\">"+ "test <p> test <p> test <p> test <p> test <p> test"+ "</div>"+ "</div>"; editorPane.setText(html); this.getContentPane().add(editorPane); } public static void main(String[] args) { SwingTester st = new SwingTester(); st.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); st.setSize(800, 600); st.setVisible(true); } }
Similar Threads
-
jeditorpane help parsing html
By asifsolkar in forum Advanced JavaReplies: 4Last Post: 12-14-2007, 05:23 AM -
java copy paste cut and undo functions
By Mr tuition in forum AWT / SwingReplies: 1Last Post: 12-09-2007, 12:02 AM -
JEditorPane
By drmmr11 in forum Java AppletsReplies: 0Last Post: 08-02-2007, 06:08 PM -
Adding custom highlight to JEditorPane
By andrewb in forum AWT / SwingReplies: 0Last Post: 06-22-2007, 06:48 PM -
How to implement Cut and Paste
By Jamie in forum AWT / SwingReplies: 2Last Post: 05-31-2007, 06:15 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks