• Post Reply Bookmark Topic Watch Topic
  • New Topic

Checkbox label formatting  RSS feed

 
Chris Bean
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • 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.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!