title: Java: JFrame on exit actions closes anyway even if "No" is clicked
body: <p>Do you know why my JFrame closes anbyway even if I click the "No" Button? This is my code:</p>
  
  <pre><code>jframe.addWindowListener(new java.awt.event.WindowAdapter() {
          @Override
          public void windowClosing(java.awt.event.WindowEvent windowEvent) {
              int confirm = JOptionPane.showOptionDialog(jframe,
                      "Sei sicuro di voler chiudere EconomatoUTL?",
                      "Attenzione!", JOptionPane.YES_NO_OPTION,
                      JOptionPane.QUESTION_MESSAGE, null, null, null);
  
              if (confirm == JOptionPane.YES_OPTION) {
  
                  Runtime runtime = Runtime.getRuntime();
                  try {
                      runtime.exec("cmd /C basexserver.bat stop");
                  } catch (IOException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
                  System.exit(1);
              }
          }
      });
  </code></pre>
  
  <p>I've found it in several forums and they say it works...
  Where's the mistake?</p>