previous | start | next

## Radio Buttons

- For a small set of mutually exclusive choices, use radio buttons or a combo box
- In a radio button set, only one button can be selected at a time
- When a button is selected, previously selected button in set is automatically turned off
- In previous figure, font sizes are mutually exclusive:

      JRadioButton smallButton = new JRadioButton("Small");
      JRadioButton mediumButton = new JRadioButton("Medium");
      JRadioButton largeButton = new JRadioButton("Large");

      // Add radio buttons into a ButtonGroup so that
      // only one button in group is on at any time
      ButtonGroup group = new ButtonGroup();
      group.add(smallButton);
      group.add(mediumButton);
      group.add(largeButton);

previous | start | next