Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / July 2006

Tip: Looking for answers? Try searching our database.

Problem Inserting HTML: tags in a JEditorPane

Thread view: 
fiziwig - 01 Aug 2006 00:00 GMT
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:
"&lt;b&gt;selected text&lt;/b&gt;" 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.