Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

dynamic text color for radiobutton?

 
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
 
Marshal
Posts: 70384
283
  • 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.
 
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
 
Aaaaaand ... we're on the march. Stylin. Get with it tiny ad.
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic