title: How do I send information from my Overridden ActionListener method to the main method in Java?
body: <p>Basically, I'm a newbie creating a program that gives questions, randomizes the index of the right answer and then displays the questions in a JFrame.
  I can easily perform any tasks that I add to this ActionListener method:</p>
  
  <pre><code>@Override
      public void actionPerformed(ActionEvent e) {
          if (e.getActionCommand().equals("1")) {
              System.out.println("whatever");
              JOptionPane.showMessageDialog(null, "correct!", 
                  "", JOptionPane.PLAIN_MESSAGE);
          } else {
          JOptionPane.showMessageDialog(null, "wrong!", 
                  "", JOptionPane.PLAIN_MESSAGE);
      }
  }
  </code></pre>
  
  <p>The program gets the "1" from setActionCommand given in the main method, yet I want the Listener to return to the main method something that when the correct radiobutton is clicked, then the next question will be displayed as well.
  The main method is made like:</p>
  
  <pre><code>while (therearestillquestionsleft) { /* do everything */ }
  </code></pre>
  
  <p>so I need the program to wait in the loop until the right answer is clicked.
  How can I achieve that?</p>