Trying to align children(labels) of 2 different HBoxes, which was created by the same method:
public HBox addHBox() {
HBox hbox = new HBox(10);
hbox.setLayoutX(10);
hbox.setPrefWidth(Pane.getWidth());
hbox.setPrefHeight(Pane.getHeight());
return hbox;
}
The LayoutY is different, and changed after the creation of each HBox. Thus, I want to accompish that added child[i] of the HBox1, would be right below child[i] of the HBox2.
Note: the size of the children should not matter! (this is what bothers me)
I tried
hbox2.setMinWidth(hbox1.getMinWidth());
and
hbox2.setPrefWidth(hbox1.getPrefWidth());
and
hbox2.setMaxWidth(hbox1.getMaxWidth());
Nothing seems to help. Any ideas? P.S. I know that i can use gridPane, but it's not in this case
Your
HBox
only classifies yourNodes
one side of the other horizontally, and in your case I suppose that you use aText
control to display your String, I don't say that it is a bad idea but I think that the width of yourNode
(Text
) depends on the length of the string which gives an unpredictable and disorderly display, so why not use aLabel
, the advantage with this control is that you can define the Width of the background what Will give your String a limit and allow an ordered display !