For simpler layout managers, such as HBox, you can also control how nodes behave under pressure.
For example, let's look at the browser address bar again: there are some buttons on the left, a text field for the address, and some buttons on the right—but we want only the address box to change size:
API methods for that are static and called setHgrow() for HBox and setVgrow() for VBox. GridPane has both of them too. For some reason, they are static and their usage looks as follows:
// chapter7/resizing/HGrowDemo.java
HBox root = new HBox(10);
TextField address = new TextField("http://stackoverflow.com");
HBox.setHgrow(address, Priority.ALWAYS);
root.getChildren().addAll(
new Button("Back"), new Button("Home"),
address, new Button("Go"));
root.setPadding(new Insets(10...