import java.awt.*; import javax.swing.*; import java.awt.event.*; public class radio { private JRadioButton btn1 = new JRadioButton("Cube"); private JRadioButton btn2 = new JRadioButton("Pyramid"); private JRadioButton btn3 = new JRadioButton("Sphere"); public radio() { JFrame frame = new JFrame("java radio button example"); frame.setSize(320, 240); Container content = frame.getContentPane(); ButtonGroup buttons = new ButtonGroup(); buttons.add(btn1); buttons.add(btn2); buttons.add(btn3); JPanel buttonPanel = new JPanel(); buttonPanel.add(btn1); buttonPanel.add(btn2); buttonPanel.add(btn3); btn1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { btn2.setEnabled(false); btn3.setEnabled(false); } }); content.add(buttonPanel, BorderLayout.SOUTH); frame.setVisible(true); } public static void main(String[] args) { new radio(); } }