title: Java swing - when cancel button clicked don't loop
body: <p>I have a gui, that is having a Login prompt added. </p>
  
  <pre><code>while(notValidLogIn){
          LoginPrompt.getDetails() //a static method that 
  }
  </code></pre>
  
  <p>Hwoever, the loginPrompt is a Jdialog, with a parent JFrame. How can I stop looping of cancel clicked, I could put System.exit(0) in cancel action performed. But don't want to stop everything, I want something like :</p>
  
  <pre><code>while(notValidLogIn &amp;&amp; LoginPrompt.isNotCancelled()){
    LoginPrompt.getDetails(); //a static method that creates an instance of login JDialog()
  }
  </code></pre>