title: JAVAFX-8 CANCEL ACTION Close the stage, using Dialog from controlfx in Javafx?
body: <p>I'm using dialog box from ControlFx in my JavaFX app. but on clicking Cancel button it close the application.</p>
  
  <pre><code>package testing;
  
  import javafx.application.Application;
  import javafx.event.ActionEvent;
  import javafx.event.Event;
  import javafx.event.EventHandler;
  import javafx.scene.Scene;
  import javafx.scene.control.Button;
  import javafx.scene.layout.StackPane;
  import javafx.stage.Stage;
  import org.controlsfx.control.action.Action;
  import org.controlsfx.dialog.Dialog;
  import org.controlsfx.dialog.Dialogs;
  
  public class NewFXMain extends Application {
  
  @Override
  public void start(Stage primaryStage) {
      Button btn = new Button();
      btn.setText("Say 'Hello World'");
      btn.setOnAction(new EventHandler&lt;ActionEvent&gt;() {
  
          @Override
          public void handle(ActionEvent event) {
              System.out.println("Hello World!");
          }
      });
  
      StackPane root = new StackPane();
      root.getChildren().add(btn);
  
      Scene scene = new Scene(root, 300, 250);
  
      primaryStage.setTitle("Hello World!");
      primaryStage.setScene(scene);
      primaryStage.show();
      primaryStage.setOnCloseRequest(new EventHandler() {
          public void handle(Event t) {
              Action response = Dialogs.create()
                      .owner(new Stage())
                      .title("Exit ??")
                      .masthead("Do you want to Exit ??")
                      .actions(Dialog.Actions.OK, Dialog.Actions.CANCEL)
                      .showConfirm();
  
              if (response == Dialog.Actions.OK) {
                  primaryStage.hide();
                  System.exit(0);
  // ... user chose OK
              } else if (response == Dialog.Actions.CANCEL){
  
              }
  
          }
      });
  
  }
  
  /**
   * @param args the command line arguments
   */
  public static void main(String[] args) {
      launch(args);
  }
  
  }
  </code></pre>
  
  <p>Am i implementing it the wrong way or is it a bug in the conrolfx ? tried warning dialog also same happens there too. I also tried other dialogs with YES, NO and cancel  actions. I'm using netbeans 8.0 with jdk 8 on ubuntu 14.04. </p>