This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Making radio buttons noneditable

 
Bai Shen
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any way to make a radio button noneditable? I want to use them as an indicator of what's selected, but I don't want people to click and change the selection. Is this possible? TIA.
 
Brian Cole
Author
Ranch Hand
Posts: 908
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bai Shen:
Is there any way to make a radio button noneditable? I want to use them as an indicator of what's selected, but I don't want people to click and change the selection.


Do you mean JRadioButton or JCheckBox? No matter, either way this
is what setEnabled(false) does. That will also cause the LnF to
give an indication to the user that the button is disabled, usually
by using a grey color.

If you want disabled behaviour without the greyed-out color (not
necessarily recommended) you can either mess with the painting
code or you can play tricks with the ButtonModel like this:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic