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
Solved

Changing text color in JLabel

Posted on 2002-04-09
4
1,272 Views
Last Modified: 2007-12-19
Hi,
How do I change font color on JLabel?
0
Comment
Question by:Leonid99
  • 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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 will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

839 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