previous |
start |
next
Radio Buttons
- Radio buttons are mutually exclusive
- Button group turns one button off when the next one is turned
on
- sButton = new JRadioButton("Small");
mButton = new JRadioButton("Medium");
lButton = new JRadioButton("Large");
ButtonGroup group = new ButtonGroup();
group.add(sbutton);
group.add(mbutton);
group.add(lbutton);
- Button group doesn't place buttons into panel--need to add
them:
panel.add(sButton);
- In action listener, test if selected
if (sButton.isSelected()) . . .
previous |
start |
next