JavaFX MDI window: how to make a AnchorPane responsive to AnchorPane Pai

0

I want to know how do I make my internal AnchorPane responsive example: I have a main screen and on this main screen has a configuration button.

When I click this button, it opens another AnchorPane inside the main AnchorPane. The problem is that when the internal AnchorPane is opened, it is not the size of the parent AnchorPane, that is, if I resize the Main AnchorPane, the AnchorPane inside it does not resize it, it stays the default size that is in my SceneBuilder.

How can I make my internal AnchorPane resize along with the main AnchorPane?

This is the button code that adds the internal AnchorPane

 @FXML
 private AnchorPane adicionarTela; 

@FXML
    public void abrirTelaConficuracao() throws IOException, Exception {
        AnchorPane a = (AnchorPane) FXMLLoader.load(getClass().getResource("TelaConfiguracao.fxml"));
        adicionarTela.getChildren().add(a);

    }
    
asked by anonymous 15.08.2017 / 18:15

1 answer

0

You're probably not setting the anchors. In FXML, just go to the SceneBuilder in the Layout section of the AnchorPane child:

Inthecode(whichisyourcase),youwillhavetoputtheanchorsmanually:

AnchorPanea=(AnchorPane)FXMLLoader.load(getClass().getResource("TelaConfiguracao.fxml"));
adicionarTela.setTopAnchor(a, 0.0);
adicionarTela.setBottomAnchor(a, 0.0);
adicionarTela.setLeftAnchor(a, 0.0);
adicionarTela.setRightAnchor(a, 0.0);

adicionarTela.getChildren().add(a);
    
15.08.2017 / 21:31