This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes HTMLEditorKIT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "HTMLEditorKIT" Watch "HTMLEditorKIT" New topic
Author

HTMLEditorKIT

vidya sagar
Ranch Hand

Joined: Mar 02, 2005
Posts: 580
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?.Thanks in advance.
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
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 ]

bitguru blog
vidya sagar
Ranch Hand

Joined: Mar 02, 2005
Posts: 580
Thanks Brian.You got my point.i was facing HTML limitations in Swing.Am gonna try some 3rd party editors.If you know/suggest any 3rd part editors, please let me know.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HTMLEditorKIT
 
Similar Threads
JTextPane Questions
Text Plain and JTextPane
Unicode equivalent for &lt;br&gt;. Any idea?
Problem viewing German umlauts in certain Outlook 20003
Using JTextPane for html