title: How to pause program mid loop to wait for a button press java - action listener
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1641209/how-can-i-wait-for-a-button-press-in-a-loop">How can I wait for a button press in a loop?</a>  </p>
  </blockquote>
  
  
  
  <p>I think this question has been asked before however I have not found a response that solves my situation.</p>
  
  <p>I currently have a chess program (command line) that allows a user to input the coordinates of the square holding the piece that they would like to move.  The beginning works like this.</p>
  
  <pre><code>boolean success;
  do {
      success = true;
  
      // take in coordinates;
  
      // perform checks such as not empty square etc;
  
      if (/*problem found*/) {
          // print error message;
          success = false;
      }
  }
  while (!success);
  </code></pre>
  
  <p>This works great when running in a command line because each time the loop is run, the program pauses execution to wait for the user to input the coordinates.  However, now I want to implement this with a GUI using buttons and action listeners.  The most convenient solution would be not to change the code apart from the input coordinates section  which would be replaced with something such as,</p>
  
  <pre><code>pause program;
  user presses button which sets coordinates;
  when button pressed program continues;
  perform checks…;
  </code></pre>
  
  <p>How can this be done?
  Is there a method in java that says wait for button press?
  This method would have to insure that other parts of the program such as painting the GUI does not stop.</p>