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 );