title: Get value that been selected from radio button in java
body: <pre><code>import javax.swing.*;
  
  import java.awt.*;
  
  public class RadioButtonTest extends JFrame {
  
  private JTextField jtfAnswer = new JTextField(10);
  private JRadioButton jrbMale = new JRadioButton("Male");
  private JRadioButton jrbFemale = new JRadioButton("Female");
  private JButton jbSubmit = new JButton("Submit");
  
  public RadioButtonTest(){
      setLayout(new GridLayout(5,1));
  
      ButtonGroup group = new ButtonGroup();
      group.add(jrbMale);
      group.add(jrbFemale);
  
      add(new Label("Select gender:"));
      add(jrbMale);
      add(jrbFemale);
      add(jtfAnswer);
      add(jbSubmit);
  
      setTitle("Radio Button");
      setLocationRelativeTo(null);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setLocation(200, 200);
      setSize(150, 150);
      setVisible(true);
  }
  
  public static void main(String[] args) {
      new RadioButtonTest();
  }
  }
  </code></pre>
  
  <p>I know should add an <code>actionlistener</code> to obtain the selected values , but what is the content I should code in the <code>actionlistener</code> ?</p>