I had the same problem (the way I got to this page) and I fixed it by putting a text box in the HBox. A problem may arise if the text field is only placed in the parent component, where the siblings are layout managers. For example, placing it in a GridLayout along with a VBox, HBox, or child GridLayout. Here is the code that did this;
HBox hbForTextField = new HBox(); TextField sample = new TextField(); sample.setAlignment(Pos.CENTER);
You can then add HBox to the root or other parent layout manager.
source share