- Mastering JavaFX 10
- Sergey Grinev
- 71字
- 2021-06-25 21:21:54
BorderPane layout manager
BorderPane suggests several positions to align each subnode: top, bottom, left, right, or center:
![](https://epubservercos.yuewen.com/0A344C/19470392808882006/epubprivate/OEBPS/Images/Chapter_13.jpg?sign=1739363369-7xZSNGmgbYlqhe2gylAbyzSoHgeGsUda-0-514f9acbee38e252d1d5fbf08b80e50f)
Refer to the following code:
BorderPane root = new BorderPane();
root.setRight(new Text("Right "));
root.setCenter(new Text("Center"));
root.setBottom(new Text(" Bottom"));
root.setLeft(new Text(" Left"));
Text top = new Text("Top");
root.setTop(top);
BorderPane.setAlignment(top, Pos.CENTER);
Note the last line, where the static method is used to adjust top-element horizontal alignment. This is a JavaFX-specific approach to set Pane constraints.