IntelliJ Java IDE
The moose likes Applets and the fly likes Label : can change font OK.  How about color? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Applets
Reply Bookmark "Label : can change font OK.  How about color?" Watch "Label : can change font OK.  How about color?" New topic
Author

Label : can change font OK. How about color?

Don Smathers
Ranch Hand

Joined: Mar 04, 2001
Posts: 31
LL&P --- I am novice. Would like to have choice of standard colors when add( textLabel ) to a panel, but cannot figure out how to do so. Can you help? Thanks !!
Ashwin Desai
Ranch Hand

Joined: Jul 17, 2000
Posts: 124
Hi,
you can change colors using
label.setForeground(new Color(x,y,z)); // For Foreground (Font)
&
label.setBackground(new Color(x,y,z)); // For Background
x,y,x are the RGB values for the colors. Alternatively you can use defined static contants in the Color class as
Color.black, Color.red, Color.green, Color.gray, Color.lightGray, Color.white, Color.blue & maybe more.
Hope this helps.
Don Smathers
Ranch Hand

Joined: Mar 04, 2001
Posts: 31
Many thanks --- worked perfectly --- Don
Originally posted by Ashwin Desai:
Hi,
you can change colors using
label.setForeground(new Color(x,y,z)); // For Foreground (Font)
&
label.setBackground(new Color(x,y,z)); // For Background
x,y,x are the RGB values for the colors. Alternatively you can use defined static contants in the Color class as
Color.black, Color.red, Color.green, Color.gray, Color.lightGray, Color.white, Color.blue & maybe more.
Hope this helps.

 
IntelliJ Java IDE
 
subject: Label : can change font OK. How about color?
 
Threads others viewed
Hide Standart Buttons in Taskbar
ConnectionFactory lookup returns null
reloading div dynamically
Increase memory for tomcat
Tsunami caused time shift?
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com