Meaningless Drivel is fun!*
The moose likes Swing / AWT / SWT and the fly likes dynamic text color for radiobutton? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "dynamic text color for radiobutton?" Watch "dynamic text color for radiobutton?" New topic
Author

dynamic text color for radiobutton?

Johann Dobbins
Ranch Hand

Joined: Oct 16, 2008
Posts: 62
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

Joined: Oct 13, 2005
Posts: 38519
    
  23
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

Joined: Oct 16, 2008
Posts: 62
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

Joined: Dec 13, 2008
Posts: 112
From javax.swing.UIManager you get javax.swing.UIDefaults there you can change colors too for JRadioButton's http://nadeausoftware.com/node/85#RadioButton
 
wood burning stoves
 
subject: dynamic text color for radiobutton?