Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

dynamic text color for radiobutton?  RSS feed

 
Johann Dobbins
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to be able to customize the text color of my jRadioButtons. I would like them to use the color of titledBorders for my native l&f. I'm having some trouble doing this. I assume I have to set the buttonUi for my radiobuttons to some sort of custom extension, in which I set a different font for selected buttons. I haven't been able to figure out how to do this. Any thoughts?

thanks
 
Campbell Ritchie
Sheriff
Posts: 53769
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have text on a radio button? I thought you had a JLabel next to it with text on. There are setBackground() and setForeground() methods which allow colour changes; have you found them?
 
Johann Dobbins
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Do you have text on a radio button? I thought you had a JLabel next to it with text on. There are setBackground() and setForeground() methods which allow colour changes; have you found them?


The radio button does have text, no label. The problem with the setForeground method, is if i set the color using it, the radiobutton doesn't turn grey when not selected. not a big deal, and probably one that i could handle with listeners. But there might a "more correct" solution by using a buttonUI? I don't want to have to add listeners to all the radiobuttons in my app.
 
Mikko Kohtamäki
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From javax.swing.UIManager you get javax.swing.UIDefaults there you can change colors too for JRadioButton's http://nadeausoftware.com/node/85#RadioButton
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!