import javax.swing.*; import java.awt.FlowLayout; import java.awt.event.*; public class Exec73 extends JFrame implements ActionListener{ /** * @param args */ public static void main(String[] args) { new Exec73(); } Exec73(){ this.setTitle("Exec73 Test"); this.setSize(400,400); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLocationRelativeTo(null); jrb1 = new JRadioButton("Foot Ball"); jrb2 = new JRadioButton("Basket Ball"); jrb3 = new JRadioButton("Swim"); text = new JTextField(10); jrb1.addActionListener(this); jrb2.addActionListener(this); jrb3.addActionListener(this); this.setLayout(new FlowLayout()); ButtonGroup g = new ButtonGroup(); g.add(jrb1);g.add(jrb2);g.add(jrb3); add(jrb1); add(jrb2); add(jrb3); add(text); setVisible(true); pack(); } public void actionPerformed(ActionEvent e) { JRadioButton tjrb = (JRadioButton)e.getSource(); text.setText(tjrb.getActionCommand()); } JRadioButton jrb1,jrb2,jrb3; JTextField text; }