title: JOptionPane cancel button
body: <p>Guys Im trying to use the JOptionPane but the cancel button is responding as if I entered a wrong input value and does not exit the programm. Any ideas whould be very useful!</p>
  
  <pre><code>int n = 0, k = 0;
  
  Students stu = new Students();      
  
  while (n &lt;= 0) { 
  
       try { 
         n = Integer.parseInt(JOptionPane.showInputDialog(stu, "Enter the number of people","Input", JOptionPane.INFORMATION_MESSAGE));
  
         if (n &lt;= 0) {
          OptionPane.showMessageDialog(stu, "You have given a wrong input!", 
               "Warning", JOptionPane.WARNING_MESSAGE);
         }    
      }
  
      catch (Exception e) { 
            JOptionPane.showMessageDialog(stu, "You have given a wrong input!",
                 "Warning",  JOptionPane.WARNING_MESSAGE);
            n = 0; 
      }
  }
  </code></pre>