changes from the reviewers implemented, some more error handling implemented with the load function of the show method
This commit is contained in:
parent
69ae19711b
commit
4414328fe0
1 changed files with 12 additions and 7 deletions
|
|
@ -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
|
* Constructs a Navigation Object that uses a fxml object and Pane that will allow to switch UI screens
|
||||||
* @param x
|
* @param x - a MyFXML Object
|
||||||
* @param y
|
* @param y - a Pane Object
|
||||||
*/
|
*/
|
||||||
public Navigation(MyFXML x, Pane y){
|
public Navigation(MyFXML x, Pane y){
|
||||||
this.myFXML = x;
|
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
|
* 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
|
* 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){
|
public void show(String fxmlpath){
|
||||||
|
|
||||||
|
try{
|
||||||
var result = myFXML.load(Object.class, fxmlpath); //stores the result of the load method in result
|
var result = myFXML.load(Object.class, fxmlpath); //stores the result of the load method in result
|
||||||
Parent uiRoot = result.getValue();
|
Parent uiRoot = result.getValue();
|
||||||
screen.getChildren().setAll(uiRoot);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue