как сделать переключение между сценами в javafx?

Помогите, надо что бы главный fxml файл менялся при этом окно было тоже самое, а на деле создаётся другое окно.

MainPage.java

package com.example.appjavafx;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import java.io.IOException;
import java.util.Objects;

public class MainPage extends Application {
    private static final String directory_icon = "file:D:/IntelliJProjects/AppJavaFX/src/main/resources/com/example/appjavafx/pages/ICON.png";

    @Override
    public void start(Stage stage) throws IOException {
        Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("pages/main_page.fxml")));
        stage.setScene(new Scene(root, 523.0, 414.0));
        stage.setTitle("Приложение");
        stage.getIcons().add(new Image(directory_icon));
        stage.centerOnScreen();
        stage.setResizable(false);

        stage.show();
    }

    public static void main(String[] args) {
        launch();
    }
}

SettingsPage.java

package com.example.appjavafx;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;
import java.util.Objects;

public class SettingsPage extends Application {
    private static final String directory_icon = "D:/IntelliJProjects/AppJavaFX/src/main/resources/com/example/appjavafx/pages/ICON.png";
    public Stage stage = new Stage();

    @Override
    public void start(Stage stage) throws IOException {
        Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("pages/settings_page.fxml")));
        stage.setTitle("Параметры");
        stage.centerOnScreen();
        stage.setResizable(false);
        stage.setScene(new Scene(root, 523.0, 414.0));
        stage.show();
    }
    public void window() throws IOException {
        start(stage);
    }
}

MainAppController.java

package com.example.appjavafx.Controllers;

import com.example.appjavafx.*;
import javafx.fxml.FXML;
import javafx.stage.Stage;
import java.io.IOException;

public class MainAppController {
    SettingsPage settings = new SettingsPage();
    Stage stage = new Stage();

    @FXML
    protected void Exit() throws IOException {
        //метод Exit отвечает за завершение работы приложения
        ModalExitWindow ext_p = new ModalExitWindow();
        ext_p.exit();
    }

    @FXML
    public void Settings() throws Exception {
        settings.window();
    }
}


Ответы (0 шт):