• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Checkbox label formatting

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
At the risk of asking a stupid question, I have written a program which contains various labels, textboxes, checkboxgroups and checkboxes.
The problem is that I would like the font color to be white. By setting component.setForeground(Color.white) (where component is the name of a Panel object), all text becomes white with the exception of checkboxes (whether or not included in a checkboxgroup).
I have tried explicitly setting the foreground color of a checkbox using checkbox.setForeground(Color.white) (where checkbox is the name of a Checkbox object) but this has no effect.
Am I missing something here?
Equally I need to figure out how I can align the label of a checkbox with the checkbox.
Any pointers would be greatly appreciated.
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Chris,
Welcome to JavaRanch.
At the risk of asking a stupid question, ...
It's OK Chris, we allow five stupid questions for each stupid answer at JavaRanch. Like the US government I always seem to be running a deficit.
For your question, the problem with components like buttons and checkboxes is that their appearance is determined by the pluggable look and feel or plaf that is currently selected. I'm not sure about this (more stupid answers in the red) but you may be able to set the color of the text by using HTML like this:

For the plaf approach, take a look at the UIManager class in the API docs.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't believe him Chris, if there were a limit on the number of stupid questions, answers and statements per user at JavaRanch this would be a lonely place just inhabited by Nerdy looking Geeks.
Since we KNOW that there are an unusually high percentage of good looking folks here (we know this because Map told us so ) there must be not limit on such things. That plus the fact that they wouldn't even let me NEAR the place in that case . . .
At any rate - I am going to move this to the Swing forum. Good Luck.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic