Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to set background color on a JLabel

Status
Not open for further replies.

Jimguld

Programmer
Mar 4, 2003
26
DK
Hi
I have tried to set the background color of a JLabel. It should be very simple, however it does not seem to work. I am trying to use the setBackGround method, and teh JLabel is added to a JPanel...


JLabel label = new JLabel("Hello World");
label.setBackGround(java.awt.Color.red);


Any suggestions ...

 
You must also set opaque to true:

label.setOpaque(true);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top