Include a fxml via code by a controller

0

Hello, I have the following question. I have two fxml: UserList.fxml and UserProperties.fxml. You need to include the UserList inside UserProperties, but it can not be by fxml, as this will not always happen, only if a certain condition is true. Would anyone have any idea how I could do this for the controller?

Thank you.

    
asked by anonymous 27.01.2015 / 13:49

1 answer

0

I could add both in a stackpane in the same fxml and leave hidden, only showing when the condition is satisfied, could even use the visibility property and bind with that condition.

Another way would be to add fxml to scene or a panel.

    FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource(caminho));
    Pane parent;
    try {
        parent = (Pane) loader.load();
        //adicionar a scene ou pane
        scene.add(parent);
    } catch (IOException ex) {
        Logger.getLogger(AplicacaoController.class.getName()).log(Level.SEVERE, null, ex);
    }
    
23.08.2015 / 08:52