Solved

Changing text color in JLabel

Posted on 2002-04-09
4
1,278 Views
Last Modified: 2007-12-19
Hi,
How do I change font color on JLabel?
0
Comment
Question by:Leonid99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 7

Expert Comment

by:Igor Bazarny
ID: 6928773
label.setForegorund()
0
 
LVL 7

Expert Comment

by:Igor Bazarny
ID: 6928775
Oops,
it should be label.setForeground()
0
 
LVL 7

Expert Comment

by:tomboshell
ID: 6930610
Use some html coding in the label's string.  Then set the font in the html.  
ex.
String lTxt=new String("<html><font color='blue'>Hey my font color is set!</font></html>");
JLabel lab=new JLabel(lTxt);

Then you can also use the font families, bold, italic and such that are available to html.  This also works great when you are setting the message in a JOptionPane and want to bring empahsis to certain lines or are working on formating with the <p> tag.  

Tom
0
 

Accepted Solution

by:
cini_gm earned 50 total points
ID: 6930625
Its simple..
 Suppose ur label is label1
 label1.setForeground(Color);
eg:
 label1.setForeground(Color.blue);
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Suggested Courses

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question