title: How to wait for a mouse click
body: <pre><code>class GameFrameClass extends javax.swing.JFrame  {
  
      public void MyFunc()
      {
          UserButton.setText(Str);
          UserButton.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  UserButtonActionPerformed(evt);
              }
          });
          getContentPane().add(UserButton);
      }
  
      private void UserButtonActionPerformed(java.awt.event.ActionEvent evt) {
  
          //print some stuff after mouse click
      }
  }
  </code></pre>
  
  <p>In someother class i define this function</p>
  
  <pre><code>void functionAdd()
  {
      GameFrameClass gfc = new GameFrameClass()
      gfc.MyFunc()
      System.out.println("PRINT THIS AFTER MOUSE CLICK")  
  }
  </code></pre>
  
  <p>If someone can look into this code. I want to wait on the mouse click . Is there a way i can print the line  System.out.println("PRINT THIS AFTER MOUSE CLICK") after the mouse is being clicked . For now this happens immediately and i am not able to wait for the mouse click . Is there a way of doing it ? Apart from doing it inside the function  UserButtonActionPerformed() . Please let me know .</p>