title: Java Dialog close returns same value as cancel?
body: <p>I'm trying to write a dialog function that returns an int value (1, -1, or 0) according to the user's choice ('confirm', 'no', or close the dialog).</p>
  
  <p>But whenever I close the dialog, it returns the same value as selecting the 'no' button.</p>
  
  <p>is there a way to solve this issue?</p>
  
  <p>Thank you in advance :)</p>
  
  <blockquote>
    <p>/**   * Shows a confirm box and returns an integer value of the user
    selection      * @param title      * @param text   * @return       * @return 1
    if confirmed, -1 if not confirmed, 0 if canceled   */</p>
  </blockquote>
  
  <pre><code>public static int strictConfirmBox(String title, String text, String yesString, String noString) {
      ButtonType okBttn = new ButtonType(yesString, ButtonData.YES);
      ButtonType noBttn = new ButtonType(noString, ButtonData.NO);
  
      Alert alert = new Alert(Alert.AlertType.CONFIRMATION, text, noBttn, okBttn);
      alert.setTitle(title);
      alert.setHeaderText(null);
      alert.setGraphic(null);
      Label msg = new Label(text);
      msg.setWrapText(true);
      alert.getDialogPane().setContent(msg);
  
      alert.showAndWait();
  
  
  
      if(alert.getResult()==ButtonType.CLOSE){
          //closed dialog
          return 0;
      }else if(alert.getResult()==ButtonType.YES){
          //selected yes
          return 1;
      }
      // else if(alert.getResult()==ButtonType.NO){
      //selected no
      return -1;
  }
  </code></pre>