Mix bold and plain in a JLabel.

A

Aaron Fude

Hi,

I find that the HTML JLabel functionality is too slow for my purposes.
But all I'm trying to do is to highlight part of the string in bold or
underline. Is there a way of doing this w/o HTML?

(I guess I could always put three labels next to each other.)

Many thanks in advance!

Aaron
 
K

Knute Johnson

Aaron said:
Hi,

I find that the HTML JLabel functionality is too slow for my purposes.
But all I'm trying to do is to highlight part of the string in bold or
underline. Is there a way of doing this w/o HTML?

(I guess I could always put three labels next to each other.)

Many thanks in advance!

Aaron

How can it be too slow? You can display huge labels with HTML text much
faster than you can read it.
 
A

Aaron Fude

How can it be too slow?  You can display huge labels with HTML text much
faster than you can read it.

Well, if it can't be too slow then how come the tutorials talk about
HTML in Swing component being slow and inefficient? That's a
rhetorical question.

My situation is that I use a JLabel as a ListCellRenderer in a
JComboBox and using html causes significant delays.
 
R

Roedy Green

I find that the HTML JLabel functionality is too slow for my purposes.
But all I'm trying to do is to highlight part of the string in bold or
underline. Is there a way of doing this w/o HTML?
You can create an icon, perhaps dynamically with drawString, and use
setIcon.
 
K

Knute Johnson

Aaron said:
Well, if it can't be too slow then how come the tutorials talk about
HTML in Swing component being slow and inefficient? That's a
rhetorical question.

My situation is that I use a JLabel as a ListCellRenderer in a
JComboBox and using html causes significant delays.

You didn't say you had a lot of them.

If all you need is bold and underline, just create your own component.
 
L

Larry A Barowski

Janusch said:
Hi Aaron,

you can use JTextArea: Set the style of your text parts youself.
Change the border of JTextArea, set editable to false.
But this solution create bigger code.

And you can copy font, colors, etc. from a reference label
to make it look like a label. Also you should make it
non-focusable.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top