title: Java, force program to wait for click inside while loop
body: <p>Okay so this isn't great code, but basically I need to force a more complicated version of this program to wait for a click while inside of a while loop. Any help on making the waitForClick() method below would be awesome. All that is supposed to happen is that the user clicks the JButton finish, and the program will set condition to false, and print "Done".</p>
  
  <p>public class GUI extends JFrame {</p>
  
  <pre><code>private static final long serialVersionUID = 3560258176733156660L;
  
  public static void main(String[] args) {
      new GUI().setVisible(true);
  }
  
  private JButton finish;
  private boolean condition;
  
  public GUI() {
      condition = true;
      setLayout(null);
      setSize(250, 120);
      setTitle("Silly");
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      finish = new JButton("Finish");
      finish.setBounds(50, 40, 100, 30);
      finish.addMouseListener(new MouseClickListener());
      add(finish);
      doThings();
  
  }
  public void doThings() {
      while (condition) {
          waitForClick();
      }
      System.out.println("Done");
  }
  
  public void waitForClick() {
      // Need this method to make program wait for the Listener below, don't know how to do this!
  
  }
  
  public class MouseClickListener implements MouseListener {
  
      public void mouseClicked(MouseEvent arg0) {
  
          if (arg0.getSource()==finish) {
              condition = false;
          }
  
      }
  
      @Override
      public void mouseEntered(MouseEvent arg0) {
  
      }
  
      @Override
      public void mouseExited(MouseEvent arg0) {
          // TODO Auto-generated method stub
  
      }
  
      @Override
      public void mousePressed(MouseEvent arg0) {
          // TODO Auto-generated method stub
  
      }
  
      @Override
      public void mouseReleased(MouseEvent arg0) {
          // TODO Auto-generated method stub
  
      }
  
  }
  </code></pre>
  
  <p>}</p>