如何在一个 window 中打开所有关卡?

how to open all stage in only one window?

我用 JavaFX 创建了一个小软件。主 window 有几个打开其他页面的按钮。但是当我点击这些按钮时,它们会打开新的 windows .

希望所有这些页面都像普通软件一样在一个 window 中打开。

这是所有这些按钮上的事件代码。

@FXML
void Agenda(ActionEvent event) {

}

@FXML
void Informations(ActionEvent event) {
    try{

        FXMLLoader loade = new FXMLLoader(getClass().getResource("/cm/Project/View/Informations.fxml"));
        VBox root = (VBox) loade.load();
        Stage stage = new Stage();
        stage.setTitle("Bernon Storage");
        stage.setScene(new Scene(root));

        stage.show();
    } catch (Exception e){
        e.printStackTrace();
    }

}

@FXML
void Inscription(ActionEvent event) {
    try{
        FXMLLoader loade = new FXMLLoader(getClass().getResource("/cm/Project/View/Inscription.fxml"));
        VBox root = (VBox) loade.load();
        Stage stage = new Stage();
        stage.setTitle("Bernon Storage");
        stage.setScene(new Scene(root));
        stage.show();
    } catch (Exception e){
        e.printStackTrace();
    }

}

@FXML
void Notes(ActionEvent event) {
    try{
        FXMLLoader loade = new FXMLLoader(getClass().getResource("/cm/Project/View/Notes1.fxml"));
        VBox root = (VBox) loade.load();
        Stage stage = new Stage();
        stage.setTitle("Bernon Storage");
        stage.setScene(new Scene(root));
        stage.show();
    } catch (Exception e){
        e.printStackTrace();
    }

}

@FXML
void Staff(ActionEvent event) {
    try{
        FXMLLoader loade = new FXMLLoader(getClass().getResource("/cm/Project/View/Staff.fxml"));
        VBox root = (VBox) loade.load();
        Stage stage = new Stage();
        stage.setTitle("Bernon Storage");
        stage.setScene(new Scene(root));
        stage.show();
    } catch (Exception e){
        e.printStackTrace();
    }

}

@FXML
void Student(ActionEvent event) {
    try{
        FXMLLoader loade = new FXMLLoader(getClass().getResource("/cm/Project/View/Student.fxml"));
        VBox root = (VBox) loade.load();
        Stage stage = new Stage();
        stage.setTitle("Bernon Storage");
        stage.setScene(new Scene(root));
        stage.show();
    } catch (Exception e){
        e.printStackTrace();
    }

}

请帮我解决这个问题。这是我唯一必须完成的项目。

请查看下面的演示,快速了解如何在同一 window 中加载不同的视图。

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ToolBar;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class Window_Demo extends Application {
    BorderPane root;
    @Override
    public void start(Stage primaryStage) throws Exception {
        root = new BorderPane();
        Scene scene = new Scene(root, 500,500);
        primaryStage.setScene(scene);
        primaryStage.show();

        Button view1 = new Button("View 1");
        view1.setOnAction(e->{
            StackPane view = new StackPane(); // Load your fxml and get the node
            view.setStyle("-fx-background-color:red;-fx-opacity:.5;");
            root.setCenter(view);
        });
        Button view2 = new Button("View 2");
        view2.setOnAction(e->{
            StackPane view = new StackPane();  // Load your fxml and get the node
            view.setStyle("-fx-background-color:green;-fx-opacity:.5;");
            root.setCenter(view);
        });
        Button view3 = new Button("View 3");
        view3.setOnAction(e->{
            StackPane view = new StackPane();  // Load your fxml and get the node
            view.setStyle("-fx-background-color:blue;-fx-opacity:.5;");
            root.setCenter(view);
        });
        ToolBar toolBar = new ToolBar(view1,view2,view3);
        root.setTop(toolBar);
    }
}