This content has been marked as final. Show 3 replies
I suspect that your issue is that the HBox resizes the inner VBox - so the VBox always takes all the available horizontal space.
Try setting the VBox max size to Region.USE_PREF_SIZE in addition to setting the HBox alignment. This should
prevent the VBox to grow horizontally.
if you want to see where the boundaries of your VBox and HBox are, you can set a background color in their style property:
hope this helps,
Using setStyle, as Daniel recommends, is an excellent tool for debugging. FWIW, I use -fx-border-color instead of -fx-background-color since very few controls, if any, use border color and the color doesn't interfere with the contents.
Hi. Try the following:
HBox hb = new HBox(); VBox vb = new VBox(); hb.getChildren().addAll(vb); vb.getChildren().addAll(new Button("Submit"), new Label("label")); vb.setAlignment(Pos.BASELINE_RIGHT); HBox.setHgrow(vb, Priority.ALWAYS); Scene scene = new Scene(hb, 300, 250);