Difficulty copying data from an HBox

0

In my project, I have a main FXML page with full body and project menus, whereas only the contents of an HBox, with ID "content", is changed as menus are clicked. Content is populated with data from other FXMLs.

The problem is that I can only change the content once. After using clean or removeAll, I can no longer change the content data, it does not give error or nothing happens.

>

Note 2: My goal is to copy data from one fxml to the current scene, but not everything, only one part. And getCenter does not help me as I only get one HBox inside the center, not everything.

Hierarchy:

Code

packagesimulador;publicclassAldeiaextendsApplication{privatestaticScenesceneAldeia;protectedstaticBorderPanefxmlAldeia;protectedstaticBorderPanefxmlEdfPrincipal;publicvoidstart(StageprimaryStage)throwsException{primaryStage.setTitle("TW Fake");

        fxmlAldeia = FXMLLoader.load(getClass().getResource("Aldeia.fxml"));
        fxmlEdfPrincipal = FXMLLoader.load(getClass().getResource("EdfPrincipal.fxml"));

        sceneAldeia = new Scene(fxmlAldeia);
        primaryStage.setScene(sceneAldeia);
        primaryStage.show();
    }

    public static void changeScreen(String src) throws IOException {
        // limpa conteúdo
        ((HBox) fxmlAldeia.lookup("#conteudo")).getChildren().clear();

        switch (src) {
        case "aldeia":
            ((HBox) fxmlAldeia.lookup("#conteudo")).getChildren()
                .addAll(((HBox) fxmlAldeia.lookup("#conteudo")).getChildren());
            break;
        case "edfPrincipal":
            ((HBox) fxmlAldeia.lookup("#conteudo")).getChildren()
                .addAll(((HBox) fxmlEdfPrincipal.lookup("#conteudo")).getChildren());
            break;
        }
    }

    public static void main(String[] args) {
        launch(args);
    }
}
    
asked by anonymous 08.03.2018 / 20:04

0 answers