• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

basic radiobutton question

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Swing Gurus,

I am trying to work through some beginner tutorials and noticed that my radiobutton would allow you to check all of the options. Do the buttons need to be placed in some type of special container? My code is below:



Thanks. I appreciate your time and help very much,
Adam
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Adam Confino wrote:I am trying to work through some beginner tutorials and noticed that my radiobutton would allow you to check all of the options. Do the buttons need to be placed in some type of special container?



You need to use a ButtonGroup. It's not a container in the GUI sense, but it's a non-graphical object that deselects the other buttons in the group when a button is selected.

If you're looking at beginner tutorials, they should mention ButtonGroup along with JRadioButton. Sun's tutorial does.


Then again, a beginner tutorial should not be having you do setLayout(null) and setBounds(...) either. It's brittle and in the long run no easier than doing it the right way.
 
Adam Confino
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a bunch! I appreciate your help!
reply
    Bookmark Topic Watch Topic
  • New Topic