Solved

Changing text color in JLabel

Posted on 2002-04-09
4
1,275 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delete Android all or certain applications data programmatically 9 153
JavaFX TableView not displaying correctly 3 162
Problem to Alipay 10 95
collection output issue 9 96
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

752 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