I have a JEditorPane using the HTMLEditorKit.
JEditorPane textRegion;
...
textRegion = new JEditorPane();
textRegion.setEditorKit(new HTMLEditorKit());
....
When I try to surround the selected text with a bold tag like this:
selected = textRegion.getSelectedText();
textRegion.replaceSelection( "<b>"+selected+</b> );
What I end up with in textRegion is that the less-than and greater-than
symbols have been replaced with their HTML-ified versions:
"<b>selected text</b>" instead of the actual tags.
How can I get a JEditorPane to take me seriously when I tell it to
insert an HTML tag?
Thanks.
--gary
fiziwig - 01 Aug 2006 00:12 GMT
I noticed that when my message posted to my reader it had converted the
ampersand-l-t-semicolon back into a less-than character. So that my
post doesn't look totally foolish, my results after
replaceSelection("<b>"+selected+"</b>") are, with spaces added to
prevent converstion:
& l t ; b & g t ; selected text & l t ; / b & g t ;
--gary