MDI Javafx Window: how to make an Anchorpane responsive to Anchorpane Parent

Asked

Viewed 1,355 times

0

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

When I click this button, opens another Anchorpane inside the main Anchorpane. The problem is that when the internal Anchorpane is opened, it does not get the size of the parent Anchorpane, that is, if I resize the Main Anchorpane, the Anchorpane inside it does not resize together, it gets the standard size that is in my Scenebuilder.

How can I make my internal Anchorpane resize together with the main Anchorpane?

This is the code of the button 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);

    }

1 answer

0


You’re probably not setting the anchors. In FXML, just go to Scenebuilder in the Anchorpane Child Layout section:

Âncoras

Already in the code (which is your case), you will have to place the anchors manually:

AnchorPane a = (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);
  • FXML anchors I had already set but now the part of the code you wrote setTopAnchor and the others I did not know I did and worked the way I wanted to thank you so much, now I have another question how I can close the internal Anchorpane without terminating my application

Browser other questions tagged

You are not signed in. Login or sign up in order to post.