From 0021df2086daa80de63e44b26fbcb9f3db13abd5 Mon Sep 17 00:00:00 2001 From: Rithvik Sriram Date: Mon, 1 Dec 2025 15:00:26 +0100 Subject: [PATCH 1/3] Basic Navigation code --- .../main/java/client/utils/Navigation.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 client/src/main/java/client/utils/Navigation.java diff --git a/client/src/main/java/client/utils/Navigation.java b/client/src/main/java/client/utils/Navigation.java new file mode 100644 index 0000000..6d76ad7 --- /dev/null +++ b/client/src/main/java/client/utils/Navigation.java @@ -0,0 +1,26 @@ +package client.utils; + +import client.MyFXML; +import javafx.scene.Parent; +import javafx.scene.layout.Pane; + +public class Navigation { + + private final MyFXML myFXML; + private Pane screen; + + public Navigation(MyFXML x, Pane y){ + this.myFXML = x; + this.screen = y; + } + + public void show(String fxmlpath){ + var result = myFXML.load(Object.class, fxmlpath); + Parent UIRoot = result.getValue(); + screen.getChildren().setAll(UIRoot); + + + } + + +} From 69ae19711b3f05b59bea7e5c093c2b0b4e4acf90 Mon Sep 17 00:00:00 2001 From: Rithvik Sriram Date: Thu, 4 Dec 2025 19:12:31 +0100 Subject: [PATCH 2/3] Code handling navigation done by a navigation class with one method --- .../src/main/java/client/utils/Navigation.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/client/src/main/java/client/utils/Navigation.java b/client/src/main/java/client/utils/Navigation.java index 6d76ad7..712b5c0 100644 --- a/client/src/main/java/client/utils/Navigation.java +++ b/client/src/main/java/client/utils/Navigation.java @@ -9,15 +9,25 @@ public class Navigation { private final MyFXML myFXML; private Pane screen; + /** + * Constructs a Navigation Object that uses a fxml object and Pane that will allow to switch UI screens + * @param x + * @param y + */ public Navigation(MyFXML x, Pane y){ this.myFXML = x; this.screen = y; } + /** + * The show function takes in an FxmlPath and changes the current pane to the value given by the path + * using the load function of the myFXML object + * @param fxmlpath + */ public void show(String fxmlpath){ - var result = myFXML.load(Object.class, fxmlpath); - Parent UIRoot = result.getValue(); - screen.getChildren().setAll(UIRoot); + var result = myFXML.load(Object.class, fxmlpath); //stores the result of the load method in result + Parent uiRoot = result.getValue(); + screen.getChildren().setAll(uiRoot); } From 4414328fe09b8998e70d9b4081780087d9475da7 Mon Sep 17 00:00:00 2001 From: Rithvik Sriram Date: Fri, 5 Dec 2025 14:12:05 +0100 Subject: [PATCH 3/3] changes from the reviewers implemented, some more error handling implemented with the load function of the show method --- .../main/java/client/utils/Navigation.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/client/src/main/java/client/utils/Navigation.java b/client/src/main/java/client/utils/Navigation.java index 712b5c0..50b4b89 100644 --- a/client/src/main/java/client/utils/Navigation.java +++ b/client/src/main/java/client/utils/Navigation.java @@ -11,8 +11,8 @@ public class Navigation { /** * Constructs a Navigation Object that uses a fxml object and Pane that will allow to switch UI screens - * @param x - * @param y + * @param x - a MyFXML Object + * @param y - a Pane Object */ public Navigation(MyFXML x, Pane y){ this.myFXML = x; @@ -22,14 +22,19 @@ public class Navigation { /** * The show function takes in an FxmlPath and changes the current pane to the value given by the path * using the load function of the myFXML object - * @param fxmlpath + * @param fxmlpath - FXML path provided to show the next pane */ public void show(String fxmlpath){ - var result = myFXML.load(Object.class, fxmlpath); //stores the result of the load method in result - Parent uiRoot = result.getValue(); - screen.getChildren().setAll(uiRoot); - + try{ + var result = myFXML.load(Object.class, fxmlpath); //stores the result of the load method in result + Parent uiRoot = result.getValue(); + screen.getChildren().setAll(uiRoot); + } + catch(Exception e) { //catches any failures thrown by the load method + System.err.println("Failed to load FXML file: " + fxmlpath); + throw new IllegalArgumentException("Cannot load FXML file: " + fxmlpath, e); + } }