Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing font size in jlabel via html

Status
Not open for further replies.

rekenaar

Technical User
Feb 16, 2005
38
ZA
Hi

I need to change the size of fonts at different places in a jlabel, thus I want to use html in the text of the jlabelto change it.

Is this possible? Because normal <font>-tag doesn't seem to work.

I'm using 1.4.2

Thank you for your time.
 
Try putting <html> at the beginning of the text, like this:

Code:
label.setText("<html><font size=2>your text");

Closing tags don't seem to be necessary unless you're switching to another font within the same label.
 
HTML text in a JLabel? Am I missing something, since I didn't think this was possible? With a JTextPane this is possible though.

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top