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 / GUI / August 2006

Tip: Looking for answers? Try searching our database.

html in a textfield

Thread view: 
Brandon McCombs - 26 Aug 2006 19:39 GMT
hello,

I want to display underlined text in a Jtextfield and I found out that
in order to do that I need to use HTML so I tried that but found out
that JTextfield doesn't render the HTML. So I tried JEditorPane and
discovered I had to set the Type to "text/html". Well I'm sure that
would work for what I need to display, however when I try to grab text
out of that I get a bunch of html in addition to the text that is just
in the textfield (all I want is the text, and no html, when I grab the
text).

Is there a  way to store html but only get plain text out of the
jeditorpane?  Can I just keep setting the Type to "text" when I need to
grab text and put it back to "text/html" when I need to set the text or
is there a better way overall to handle this?

I'm using Java 1.5 (which seems to leave out the ability for a Font
object to have underlined text despite having italics and bold; how
stupid is that?).

thanks
Philbo.B.Baggins@gmail.com - 27 Aug 2006 01:00 GMT
> hello,
>
[quoted text clipped - 17 lines]
>
> thanks

Get the document out of the Editor pane with
StyledDocument doc = (StyledDocument) JEditorPane.getDocument();
And then call doc.getText(0,doc.getLength());

I think that'll work
Brandon McCombs - 27 Aug 2006 02:52 GMT
>> hello,
>>
[quoted text clipped - 23 lines]
>
> I think that'll work

thanks man. That worked great.
Philbo.B.Baggins@gmail.com - 27 Aug 2006 10:52 GMT
> >> hello,
> >>
[quoted text clipped - 25 lines]
> >
> thanks man. That worked great.

Interestingly enough, What was the code you were using? I WANT the html
to come out of it :P
Brandon McCombs - 27 Aug 2006 19:50 GMT
>>>> hello,
>>>>
[quoted text clipped - 27 lines]
> Interestingly enough, What was the code you were using? I WANT the html
> to come out of it :P

I was just using the normal JEditorPane.getText() which is the same as
with a JTextField.


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.