Search code examples
javafxloadfxmlvbox

Setting the value of VBox to a different FXML VBox?


You can do it with a BorderPane ie:

    FXMLLoader loader = new FXMLLoader(getClass().getResource("contacts.fxml"));
    HBox root = loader.load();
    rootPane.setTop(root);
}

The VBox does not have a .set(node) method.


Solution

  • With a VBox (and with many other Panes) you just modify the children ObservableList the way you would modify any other List.

    E.g.

    // add root as bottom-most child of rootPane
    rootPane.getChildren().add(root);