title: JavaFX root Menu & Split Screen in 1 display
body: <p>I am trying to have a root menu up top &amp; then do a split screen below.</p>
  
  <p>I found a website online here "<a href="http://code.makery.ch/library/javafx-8-tutorial/part1/" rel="nofollow noreferrer">http://code.makery.ch/library/javafx-8-tutorial/part1/</a>".
  It that has the example that I am trying to do.
  I want to hard code with real codes, not use some drag and drop stuff like he does.</p>
  
  <p>So far I am able to write the program &amp; display the Menu via root &amp; run everything but I can not figure out how to add a "Split screen" below it without causing issues.</p>
  
  <p>Every time I try to add split screen implementations along with the menu in root, it will not work.</p>
  
  <p>I can do it in <code>JFrame</code>, but I want it done in JavaFX root.</p>
  
  <p>I can not find anything online about it, seriously been stumped for 4 hours on this.</p>
  
  <p><a href="https://i.stack.imgur.com/gSLBb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gSLBb.png" alt="This image is what I am trying to do."></a></p>
  
  <p>(Project title is "WorkAir")
  Here is my current code:</p>
  
  <pre><code>package application;
  
  import javafx.application.Application;
  import javafx.application.Platform;
  import javafx.event.ActionEvent;
  import javafx.event.EventHandler;
  import javafx.geometry.Orientation;
  import javafx.scene.Scene;
  import javafx.scene.control.Button;
  import javafx.scene.control.CheckMenuItem;
  import javafx.scene.control.Label;
  import javafx.scene.control.Menu;
  import javafx.scene.control.MenuBar;
  import javafx.scene.control.MenuItem;
  import javafx.scene.control.RadioMenuItem;
  import javafx.scene.control.Separator;
  import javafx.scene.control.SeparatorMenuItem;
  import javafx.scene.control.ToggleGroup;
  import javafx.scene.layout.BorderPane;
  import javafx.scene.layout.StackPane;
  import javafx.scene.paint.Color;
  import javafx.stage.Stage;
  import javafx.stage.WindowEvent;
  
  public class WorkAir extends Application {
  
      @Override
      public void start(Stage primaryStage) {
          BorderPane root = new BorderPane();
          primaryStage.setTitle("WorkAir");
  
          Scene scene = new Scene(root, 1000, 550, Color.WHITE);
  
          MenuBar menuBar = new MenuBar();
          menuBar.prefWidthProperty().bind(primaryStage.widthProperty());
          root.setTop(menuBar);
  
          primaryStage.setOnCloseRequest(new EventHandler&lt;WindowEvent&gt;() {
              @Override
              public void handle(WindowEvent t) {
                  System.out.println("Platform &amp; System Exit");
                  Platform.exit();
                  System.exit(0);
              }
          });
  
          // File Menu
  
          Menu fileMenu = new Menu("File");
          MenuItem newMenuItem = new MenuItem("New");
          MenuItem saveMenuItem = new MenuItem("Save");
          MenuItem exitMenuItem = new MenuItem("Exit");
  
          fileMenu.getItems().addAll(newMenuItem, saveMenuItem,
              new SeparatorMenuItem(), exitMenuItem);
  
          //File Menu Trees
  
          exitMenuItem.setOnAction(new EventHandler&lt;ActionEvent&gt;() {
              public void handle(ActionEvent event) {
  
                  //File Menu Trees Exit
                  Label secondLabel = new Label("Are you sure you want to exit?");
                  Button buttonNo = new Button();
  
                  buttonNo.setStyle("-fx-font: 10 arial; -fx-base: #d3d3d3;");
                  buttonNo.setTranslateX(-55);
                  buttonNo.setTranslateY(30);
  
                  Button buttonYes = new Button();
  
                  buttonYes.setStyle("-fx-font: 10 arial; -fx-base: #d3d3d3;");
                  buttonYes.setTranslateX(+55);
                  buttonYes.setTranslateY(30);
  
                  buttonNo.setText("Exit, No");
                  buttonNo.setOnAction(new EventHandler&lt;ActionEvent&gt;() {
                      @Override
                      public void handle(ActionEvent event) {
  
                          System.out.println("No");
                          Stage secondStage = (Stage) buttonNo.getScene().getWindow();
                          secondStage.close();
                      }
  
                  });
  
                  buttonYes.setText("Exit, Yes");
                  buttonYes.setOnAction(new EventHandler&lt;ActionEvent&gt;() {
                      @Override
                      public void handle(ActionEvent event) {
  
                          System.out.println("Yes");
                          Platform.exit();
                      }
  
                  });
  
                  StackPane secondaryLayout = new StackPane();
                  secondaryLayout.getChildren().add(secondLabel);
                  secondaryLayout.getChildren().add(buttonNo);
                  secondaryLayout.getChildren().add(buttonYes);
  
                  Scene secondScene = new Scene(secondaryLayout, 350, 150);
  
                  Stage secondStage = new Stage();
                  secondStage.setTitle("Exit");
                  secondStage.setScene(secondScene);
  
                  //Set position of second window, related to primary window.
                  secondStage.setX(primaryStage.getX() + 250);
                  secondStage.setY(primaryStage.getY() + 100);
                  secondStage.centerOnScreen();
  
                  secondStage.show();
              }
          });
  
          //2nd Menu
          Menu secondMenu = new Menu("2nd");
          CheckMenuItem htmlMenuItem = new CheckMenuItem("HTML");
          htmlMenuItem.setSelected(true);
          secondMenu.getItems().add(htmlMenuItem);
  
          CheckMenuItem cssMenuItem = new CheckMenuItem("CSS");
          cssMenuItem.setSelected(true);
          secondMenu.getItems().add(cssMenuItem);
  
          //3rd Menu
          Menu thirdMenu = new Menu("3rd");
          ToggleGroup tGroup = new ToggleGroup();
          RadioMenuItem mysqlItem = new RadioMenuItem("MySQL");
          mysqlItem.setToggleGroup(tGroup);
  
          RadioMenuItem oracleItem = new RadioMenuItem("Oracle");
          oracleItem.setToggleGroup(tGroup);
          oracleItem.setSelected(true);
  
          thirdMenu.getItems().addAll(mysqlItem, oracleItem,
              new SeparatorMenuItem());
  
          Menu Menu = new Menu("Sub Menu");
          Menu.getItems().addAll(
              new CheckMenuItem("1"),
              new CheckMenuItem("2"),
              new CheckMenuItem("3"));
  
          secondMenu.getItems().add(Menu);
  
          //Menu Bar Get All
          menuBar.getMenus().addAll(fileMenu, secondMenu, thirdMenu);
  
          primaryStage.setScene(scene);
          primaryStage.show();
      }
  
      public static void main(String[] args) {
          launch(args);
      }
  }
  </code></pre>