Hi all,
I was wondering if there is a way to change the color of a specific String in a JLabel's text without having to extend the JLabel class and re-implementing the paint method
Printable View
Hi all,
I was wondering if there is a way to change the color of a specific String in a JLabel's text without having to extend the JLabel class and re-implementing the paint method
Yes it is simple just give the setForeground() property
eg
Label1.setForeground(Color.red);
I meant a part of the Text not all of it
You can't; it will affect the whole label (all the time). The only workaround is using multiple labels or changing your component to a jeditorpane/jtextpane which is nothing like a label.
That's what I was afraid of.Quote:
Originally Posted by System_Error
Thanks anyway guys