I have managed to load a child fxml(sub UI) under a parent fxml (mainMenu UI).
I have created an AnchorPane with id "mainContent". This pane is bound to 4 sides and changes in accords to the stage.
The child window will be loaded into the "mainContent" anchorpane. However, I can't figure out how to make the child to change along with its parent "mainContent".
My child UI is called like this.
@FXML
private void mnuUserLevel_onClick(ActionEvent event) {
FXMLLoader loader = new FXMLLoader(getClass().getResource("DBedit.fxml"));
loader.setController(new DBeditEntityUserlevel());
try {
Node n = (Node)loader.load();
mainContent.getChildren().add(n);
} catch (IOException e){
System.out.println(e.getMessage());
}
}
To further illustrate my question, please see my snap shot. The red square is the child. The yellow square is the "mainContent" AnchorPane of the MainMenu parent.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…