I need some help getting components scaled on my scene graph. In the following image I have the components on the top, well spaced and everything looks nice and normal.
I did that by setting the padding on the top menu with
menu.setPadding(new Insets(30, 0, 30, 30));
and HBox.setMargin(button, new Insets(0,0,0,370)); for the button where 370 is the padding between the field and the button. Also, the text field has a preferred width of 400.
However, when I expand the window I realize the preferred width I set for the text field does not change and it is small, and the margins of the button also change, so I don't know how to set this numbers proportional to the size of the window. I am not sure if I fix this with CSS or simply java methods.
This is the code that deals with the top part where components have the issue when maximizing the window. 'pane' is an instance of BorderPane.
private void setTopMenu() {
menu = new HBox();
menu.setPadding(new Insets(30, 0, 30, 30));
button = new Button("ABCD ABCD ABCD");
tf = new TextField();
tf.setPromptText("search");
tf.setPrefWidth(400);
tf.setId("text-field");
top.getChildren().addAll(tf, button);
HBox.setMargin(button, new Insets(0,0,0,370));
pane.setTop(menu);
}


TopMenu, can't youbindthe window's width to the width of yourButtonandTextArea's width? - Marco Luzzara