simple question,
version 1.5
i have a data entry form (JPanel) which contains 3 radio buttons in a ButtonGroup. Rather than create a new JPanel every time i want to use this form, i have a method that allows me to clear all the items in the form. However, i'm having a problem setting all the JRadioButton's in the ButtonGroup to 'not selected'.
from a java tutorial it states
"There's no supported API for unselecting all the buttons."
and when i look at the code for setSelected(ButtonModel, boolean) in the ButtonGroup class, i don't understand why the method takes a second argument (or perhaps its for backwards compatability), because the code does nothing if the second argument is false:
am i missing something here - or do i just create my own ButtonGroup class
cheers,
dan
version 1.5
i have a data entry form (JPanel) which contains 3 radio buttons in a ButtonGroup. Rather than create a new JPanel every time i want to use this form, i have a method that allows me to clear all the items in the form. However, i'm having a problem setting all the JRadioButton's in the ButtonGroup to 'not selected'.
from a java tutorial it states
"There's no supported API for unselecting all the buttons."
and when i look at the code for setSelected(ButtonModel, boolean) in the ButtonGroup class, i don't understand why the method takes a second argument (or perhaps its for backwards compatability), because the code does nothing if the second argument is false:
Code:
public void setSelected(ButtonModel m, boolean b) {
if (b && m != null && m != selection) {
ButtonModel oldSelection = selection;
selection = m;
if (oldSelection != null) {
oldSelection.setSelected(false);
}
m.setSelected(true);
}
}
am i missing something here - or do i just create my own ButtonGroup class
cheers,
dan