I am trying to make the AnchorPane resize with its parent JFXDialoglayout. I tried this in scene builder, but wouldn't let me position/resize it correctly. Now I am trying to do it manually instead as seen below. As seen in the code I tried to bind the width and height of the AnchorPane to the JFXDialoglayout, but this did still not work. I also tried setting the pref height/width of them both equally, still did not work. The problem is that the height of the AnchorPane is smaller than the JFXDialogLayout but the width is the same. How do I make the heights equal?
private JFXDialogLayout getDialogLayout() {
JFXDialogLayout layout = new JFXDialogLayout();
layout.setPrefWidth(600);
layout.setPrefHeight(300);
AnchorPane pane = new AnchorPane();
pane.prefHeightProperty().bind(layout.prefHeightProperty());
pane.prefWidthProperty().bind(layout.prefWidthProperty());
Label heading = new Label("Heading");
Text body = new Text("This is the body of the dialog.");
JFXButton button = new JFXButton("ACCEPT");
pane.getChildren().addAll(heading, body, button);
layout.getChildren().addAll(pane);
return layout;
}