Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-06-2008, 04:55 PM
Sam Sam is offline
Member
 
Join Date: Feb 2008
Posts: 1
Sam is on a distinguished road
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

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); } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
jeditorpane help parsing html asifsolkar Advanced Java 4 12-14-2007 06:23 AM
java copy paste cut and undo functions Mr tuition AWT / Swing 1 12-09-2007 01:02 AM
JEditorPane drmmr11 Java Applets 0 08-02-2007 07:08 PM
Adding custom highlight to JEditorPane andrewb AWT / Swing 0 06-22-2007 07:48 PM
How to implement Cut and Paste Jamie AWT / Swing 2 05-31-2007 07:15 PM


All times are GMT +3. The time now is 09:28 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org