@Override
    public void start(Stage primaryStage) {
        this.stage = primaryStage;
        root = new StackPane();
        Button btn = new Button();
        btn.setText("Say 'Hello World'");
        btn.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
                System.out.println("Hello World!");
            }
        });


        //root.getChildren().add(btn);
        Group mazeGroup = new Group();
        //root.getChildren().add(mazeGroup);
        VBox guiBox = new VBox();
        guiBox.setAlignment(Pos.TOP_CENTER);

        MenuBar menu = new MenuBar();
        Menu file = new Menu("File");
        MenuItem openMazeFile = new MenuItem("Open Maze File");
        openMazeFile.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent t) {
                FileChooser fileChooser = new FileChooser();
                fileChooser.setTitle("Open Maze File");
                //   System.out.println(pic.getId());
                fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Maze File", "*.maze"));
                File file = fileChooser.showOpenDialog(stage);
                if (file != null) {
                    try (
                            InputStream fStream = new FileInputStream(file);
                            InputStream buffer = new BufferedInputStream(fStream);
                            ObjectInput input = new ObjectInputStream(buffer);) {
                        MazeGridDataContainer mgd = (MazeGridDataContainer) input.readObject();
                        MazeGrid mgrid = mgd.reconstructMazeGrid();
                        mazeCentered.getChildren().clear();
                        mazeGrid = mgrid;
                        mazeCentered.getChildren().add(mgrid.getGridGroup());
                        slider.adjustValue(mgrid.getSideCount());
                        mazeName = file.getName();
                    } catch (IOException | ClassNotFoundException ex) {
                        Logger.getLogger(MazeFramework.class.getName()).log(Level.SEVERE, null, ex);
                        JOptionPane.showMessageDialog(null, ex.getMessage(), ex.getClass().getName(), JOptionPane.ERROR_MESSAGE);
                    }
                }

            }
        });
        MenuItem saveMazeFile = new MenuItem("Save Maze File");
        saveMazeFile.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent t) {
                FileChooser fileChooser = new FileChooser();
                fileChooser.setTitle("Save Maze");
                fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Maze File", "*.maze"));
                //     System.out.println(pic.getId());
                File file = fileChooser.showSaveDialog(stage);
                if (file != null) {
                    if (mazeGrid != null) {
                        try (OutputStream outputFile = new FileOutputStream(file.getAbsolutePath() + ".maze");
                                OutputStream buffer = new BufferedOutputStream(outputFile);
                                ObjectOutput output = new ObjectOutputStream(buffer);) {
                            output.writeObject(mazeGrid.toDataContainer());
                        } catch (IOException ex) {
                            Logger.getLogger(MazeFramework.class.getName()).log(Level.SEVERE, null, ex);
                            JOptionPane.showMessageDialog(null, ex.getMessage(), ex.getClass().getName(), JOptionPane.ERROR_MESSAGE);
                        }

                    }
                }




            }
        });
        file.getItems().addAll(openMazeFile, saveMazeFile);

        Menu options = new Menu("Cells per row");
        CustomMenuItem cells = new CustomMenuItem();
        slider = new Slider(5, 50, 10);
        slider.setShowTickLabels(true);
        slider.setShowTickMarks(true);
        slider.setOnMouseDragged(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent t) {
                mazeCentered.getChildren().clear();
                MazeGrid mg = new MazeGrid(null, (int) (slider.getValue()), 500);
                mazeGrid = mg;
                mazeCentered.getChildren().add(mg.getGridGroup());
            }
        });
        cells.setContent(slider);


        options.getItems().addAll(cells);

        Menu execution = new Menu("Execution");
        noDiagonal = new CheckMenuItem("Diagonal Movement");
        MenuItem execute = new MenuItem("Execute");
        MenuItem benchmark = new MenuItem("Benchmark");

        execute.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent t) {
                execute();
            }
        });

        benchmark.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent t) {
                benchmark();
            }
        });



        execution.getItems().addAll(noDiagonal, execute, benchmark);



        menu.getMenus().addAll(file, options, execution);

        mazeCentered = new FlowPane();
        mazeCentered.setAlignment(Pos.CENTER);


        MazeGrid mg = new MazeGrid(null, 10, 500);
        mazeGrid = mg;
        mazeCentered.getChildren().add(mg.getGridGroup());



        guiBox.getChildren().add(menu);
        guiBox.getChildren().add(mazeCentered);

        root.getChildren().add(guiBox);
        Scene scene = new Scene(root, 500, 520);

        primaryStage.setTitle("Maze Framework");
        //  primaryStage.setResizable(false);
        primaryStage.setScene(scene);
        primaryStage.show();
    }