aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes basic radiobutton question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "basic radiobutton question" Watch "basic radiobutton question" New topic
Author

basic radiobutton question

Adam Confino
Ranch Hand

Joined: Sep 03, 2009
Posts: 48
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


Just Another Guy Hooked on Java
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
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.


bitguru blog
Adam Confino
Ranch Hand

Joined: Sep 03, 2009
Posts: 48
Thanks a bunch! I appreciate your help!
 
wood burning stoves
 
subject: basic radiobutton question