title: How to create dialog in JavaFX
body: <p>I tested to create simple dialog in JavaFX but for some reason the code is not working:</p>
  
  <pre><code>MenuBar menuBar = new MenuBar();
  
          // File menu - new, save, exit
          Menu menu = new Menu("File");
          menu.getItems().add(new MenuItem("New"));
          menu.getItems().add(new MenuItem("Save"));
          menu.getItems().add(new SeparatorMenuItem());
  
          menuBar.getMenus().add(menu);
  
          // Options menu - Preferences
          Menu options = new Menu("Options");
          options.getItems().add(new MenuItem("Preferences"));
  
          menuBar.getMenus().add(options);
  
          // Help menu - About
          Menu help = new Menu("Help");
          MenuItem about = new MenuItem("Exit");
  
  
          about.setOnAction(new EventHandler&lt;ActionEvent&gt;() {
              @Override
              public void handle(ActionEvent e) {
                  Stage dialogStage = new Stage();
                  dialogStage.initModality(Modality.WINDOW_MODAL);
                  dialogStage.setScene(new Scene(VBoxBuilder.create().
                          children(new Text("Hi"), new Button("Ok.")).
                          alignment(Pos.CENTER).padding(new Insets(5)).build()));
                  dialogStage.show();
              }
          });
  
          menuBar.getMenus().add(help);
  
          menuBar.prefWidthProperty().bind(primaryStage.widthProperty());
  
          root.getChildren().add(menuBar);
          primaryStage.setScene(scene);
          primaryStage.show();
  </code></pre>
  
  <p>I want when I click on <code>About</code> menu item to display simple dialog window with author information. Can you tell me how to correct my mistake, please?</p>