title: How to enable a button only after a radio button was pressed in java JFrame
body: <p>After a lot of googling i still haven't found what im looking for, mostly because i don't know what i'm looking for.</p>
  
  <p>Basically i want the lock in button to be disabled until one of the radio buttons is selected, and i only want one of the radio buttons to be selected at a a time.</p>
  
  <p>I haven't done any formatting yet so its still ugly.</p>
  
  <p><a href="http://puu.sh/7PZ3p/ad7da4d049.jpg" rel="nofollow">My JFrame</a></p>
  
  <p>My Code: </p>
  
  <pre><code>import java.awt.*;
  import java.awt.event.*;
  import javax.swing.*;
  import java.awt.FlowLayout;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.io.*;
  import java.util.*;
  
  public class Game extends JFrame
  {
  JLabel lblQuestion;
  JRadioButton btA;
  JRadioButton btB;
  JRadioButton btC;
  JRadioButton btD;
  JButton btLock;
  JTextField txtQuestion;
  int question = 0;
  
  public Game()
  {
      getContentPane().setLayout(null);
      setupGUI();
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
  
  void setupGUI()
  {
      txtQuestion = new JTextField();
      txtQuestion.setLocation(10,10);
      txtQuestion.setSize(100,25);
      txtQuestion.setText(Integer.toString(question));
      getContentPane().add(txtQuestion);
  
      lblQuestion = new JLabel();
      lblQuestion.setLocation(50,82);
      lblQuestion.setSize(300,50);
      lblQuestion.setText("No_Label");
      getContentPane().add(lblQuestion);
  
      btA = new JRadioButton();
      btA.setLocation(50,160);
      btA.setSize(100,50);
      btA.setText("No_Label");
      btA.setSelected(false);
      getContentPane().add(btA);
  
      btB = new JRadioButton();
      btB.setLocation(250,160);
      btB.setSize(100,50);
      btB.setText("No_Label");
      btB.setSelected(false);
      getContentPane().add(btB);
  
      btC = new JRadioButton();
      btC.setLocation(50,240);
      btC.setSize(100,50);
      btC.setText("No_Label");
      btC.setSelected(false);
      getContentPane().add(btC);
  
      btD = new JRadioButton();
      btD.setLocation(250,240);
      btD.setSize(100,50);
      btD.setText("No_Label");
      btD.setSelected(false);
      getContentPane().add(btD);
  
      btLock = new JButton();
      btLock.setLocation(150,303);
      btLock.setSize(100,50);
      btLock.setText("Lock in");
      getContentPane().add(btLock);
  
      btLock.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
              question = question + 1;
              txtQuestion.setText(Integer.toString(question));
              try{
                  ArrayList&lt;String&gt; list = questions(question);
              }catch(Exception ex){}
          }
      });
  
      setTitle("Who wants to be a millionare");
      setSize(570,400);
      setVisible(true);
      setResizable(true);
      setLocationRelativeTo(null);
  
  
  }
  
  public ArrayList&lt;String&gt; questions(int quesion) throws IOException{
      File file = new File("questions.txt");
      if (!file.exists()){
          throw new FileNotFoundException("Could not find \"users\" file");
      }
      FileReader fr = new FileReader(file.getAbsoluteFile());
      BufferedReader br = new BufferedReader(fr);
  
      ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();
      String s;
      for(int i = 0; i*4 &lt;= quesion; i++){
          br.readLine();
      }
      while((s=br.readLine()) !=null){
          list.add(s);
      }
      br.close();
      return list;   
  }
  
  public static void main( String args[] )
  {
      new Game();
  }
  }  
  </code></pre>