Code handling navigation done by a navigation class with one method
This commit is contained in:
parent
79b3c0a967
commit
69ae19711b
1 changed files with 13 additions and 3 deletions
|
|
@ -9,15 +9,25 @@ public class Navigation {
|
||||||
private final MyFXML myFXML;
|
private final MyFXML myFXML;
|
||||||
private Pane screen;
|
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){
|
public Navigation(MyFXML x, Pane y){
|
||||||
this.myFXML = x;
|
this.myFXML = x;
|
||||||
this.screen = y;
|
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){
|
public void show(String fxmlpath){
|
||||||
var result = myFXML.load(Object.class, fxmlpath);
|
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);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue