// Using a CheckboxGroup.
// This code lets you select one of three types
// of flower with three radio buttons.
// The CheckboxGroup itself is not visible.
// It does not draw a line around the CheckBoxes, for example.
// It just ensures only one option is selected
// at a time.
// It is up to you to layout the CheckBoxes in some
// logical pattern that indicates they belong together.

import java.awt.Checkbox;
import java.awt.CheckboxGroup;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

/* ... */

CheckboxGroup flowers;
Checkbox daffodil;
Checkbox impatiens;
Checkbox sunflower;

/* ... */

flowers = new CheckboxGroup();
daffodil = new Checkbox( "daffodil", flowers, true );
impatiens = new Checkbox( "impatiens", flowers, false );
sunflower = new Checkbox( "sunflower", flowers, false );

ItemListener flowerListener = new ItemListener()
   {

   public void itemStateChanged( ItemEvent e )
      {
      Checkbox picked = flowers.getSelectedCheckbox();
      boolean hePickedDaffodils = daffodils.getState();
      /* ... */
      }
   };

daffodil.addItemListener( flowerListener );
impatiens.addItemListener( flowerListener );
sunflower.addItemListener( flowerListener );
// Note you can't attach the Listener to the CheckGroup itself.

/* ... */