Originally posted by vidya sagar: In my application there is textarea in which users are allowed to paste their html content(possibly mail contents from outlook they have paste it). For that i used below code
While running,when i copied contents from outlook and pasting into application, extra brackets along with text wording 'fragments' are coming in start and end of the copying contents.
Any suggestions why this is coming so?
If you want to use HTMLEditorKit you should probably be using a JEditorPane instead of a JTextPane. (JTextPane is a subclass of JEditorPane, but is designed to be used with StyledEditorKit.)
Probably the easiest way to do this is:
JEditorPane subjectPanel = new JEditorPane("text/html", "");
Replace "" with some HTML markup if you wish. Simple, eh?
[edit: Even though what I wrote is correct, I now realize that I probably misjudged your problem. Swing's HTML support is fairly primitive, and I would guess that you're just running into the usual limitations. One example is that it doesn't handle XHTML- style self-closing tags such as <br/> correctly--it inserts visible artifacts as you describe. There's no good solution to this within Swing. Many of us have been waiting for better HTML support in Swing but it's been a while and there's no indication it's coming. Your two main choices are to simplify the HTML you expect it to display or to look for a Component (or possibly just an EditorKit) from a 3rd party.] [ October 16, 2008: Message edited by: Brian Cole ]