Insets insets = new Insets(10); BorderPane bp = new BoderPane() Node topNode = new Label("TOP"); bp.setTop(topNode); BorderPane.setMargin(topNode, insets); Node centerNode = new Label("CENTER"); bp.setTop(centerNode); BorderPane.setMargin(centerNode, insets); Node bottomNode = new Label("BOTTOM"); bp.setTop(bottomNode); BorderPane.setMargin(bottomNode, insets);
Be aware: this will result in a distance between 20 (10 above and 10 from the center) between the top and the center. Similarly for the distance between the center and the bottom.
Documentation
public static void setMargin (Node child, insert value)
Sets the value of a field for a child when it is on the border. If set, the border panel will be located with the field space around it. Setting the value to null will remove the restriction.
source share