This week's book giveaway is in the Other Open Source APIs forum. We're giving away four copies of Storm Applied and have Sean Allen, Peter Pathirana & Matthew Jankowski on-line! See this thread for details.
i have a set of radio buttons. what is the class which represents model for set of radio buttons.
how can i get a selected radio button from a group.
i am expecting one like a DefaultComboBoxModel for combo boxes.
please let me know if any is available.
You need ButtonGroup to make the radio buttons work together. That class doesn't have a method to get the selected radio button though, only the ButtonModel of the selected button. You'll need to check each of the radio buttons to see which one isSelected(). Storing them in an array may help you.
thanks for the reply.
i have one more question.
we set objects to combox so that when call getSelected i will get object.
but i case of radio buttons i can't set a object to it ,i can set only string value am i right?
Here are a couple of snippets of button group code. Hope this helps.
Joined: Oct 13, 2005
I hope you are not using the action command in a big bank of if-elses.
I am not certain, because I haven't seen all your code, but I am not convinced that "open" and "close" are suitable for radio buttons. I would have thought that is more appropriate for an ordinary button.
Joined: Nov 29, 2006
I'm simply displaying the actionCommand string in a message window opened by the action listener.