title: Closing a modal window by clicking button
body: <p>I have a window with a button. Clicking this button opens a modal window.
  Now, I want to close this second window by clicking a button, but I can't figure out how.</p>
  
  <pre><code>public class StartMenu extends Application {    
  @Override
  public void start(Stage primaryStage) {
  final Button b = new Button("Go");
  b.setOnAction(new EventHandler&lt;ActionEvent&gt;() {
  
          @Override
          public void handle(ActionEvent t) {               
             Stage stage = new Stage();
             stage.initModality(Modality.APPLICATION_MODAL);
             AnotherWindow aw = new AnotherWindow ();               
             aw.start(stage);                
          }
      });
  ((Group) scene.getRoot()).getChildren().add(b);
  primaryStage.setScene(scene);        
  primaryStage.show();
  }}
  </code></pre>
  
  <p> 
   </p>
  
  <pre><code>public class AnotherWindow extends Application {    
  @Override
  public void start(Stage primaryStage) {
  final Button b = new Button("Back");
  b.setOnAction(new EventHandler&lt;ActionEvent&gt;() {
  
          @Override
          public void handle(ActionEvent t) {               
             //Code to close window               
          }
      });
  ((Group) scene.getRoot()).getChildren().add(b);
  primaryStage.setScene(scene);        
  primaryStage.show();
  }}
  </code></pre>