• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Label : can change font OK. How about color?

 
Don Smathers
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic