|
-
Oct 6th, 2006, 11:41 AM
#1
Thread Starter
Arabic Poster
[RESOLVED] change JLabel text color
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
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Oct 7th, 2006, 09:45 AM
#2
Member
Re: change JLabel text color
Yes it is simple just give the setForeground() property
eg
Label1.setForeground(Color.red);
DIPLOMA HOLDER IN COMPUTER TECHNOLOGY 
-
Oct 7th, 2006, 10:04 AM
#3
Thread Starter
Arabic Poster
Re: change JLabel text color
I meant a part of the Text not all of it
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Oct 8th, 2006, 05:22 PM
#4
Frenzied Member
Re: change JLabel text color
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.
-
Oct 8th, 2006, 05:41 PM
#5
Thread Starter
Arabic Poster
Re: change JLabel text color
 Originally Posted by System_Error
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.
Thanks anyway guys
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|