package de.thdeg.grademanager.gui; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.Node; import javafx.scene.Scene; import javafx.stage.Stage; import java.io.IOException; public class SwitchWindowHelper { @FXML public static void switchTo(String windowTitle, ActionEvent event) throws IOException { FXMLLoader root = new FXMLLoader(Main.class.getResource(getResourceName(windowTitle))); Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); Scene scene = new Scene(root.load(), 960, 540); if (stage != null){ stage.setTitle(windowTitle); stage.setScene(scene); stage.show(); } } private static String getResourceName(String windowTitle) { switch (windowTitle) { case "Main": return "main.fxml"; case "Student Details": return "student-details.fxml"; case "Student Modification": return "student-modification.fxml"; case "CoursesOfStudy Modification": return "courses-of-study-modification.fxml"; case "CoursesOfStudy Details": return "courses-of-study-details.fxml"; case "Course Modification": return "course-modification.fxml"; } return ""; } }