- Mastering JavaFX 10
- Sergey Grinev
- 134字
- 2021-06-25 21:21:54
GridPane layout manager
GridPane is most complex layout manager; it allows users to sets rows and columns where child Nodes can be placed.
You can control a lot of constraints through the API: grow strategy, the relative and absolute sizes of columns and rows, resize policy, and so on. I won't go through all of them to avoid repeating JavaDoc, but will show only a short sample—let's make a small chessboard pattern using GridPane:
GridPane root = new GridPane();
for (int i = 0; i < 5; i++) {
root.getColumnConstraints().add(new ColumnConstraints(50));
root.getRowConstraints().add(new RowConstraints(50));
}
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
if ((i+j)%2 == 0)
root.add(new Rectangle(30, 30, Color.BLUE), i, j);
}
}
We get the following output:

推薦閱讀
- Application Development with Qt Creator(Second Edition)
- HTML5 Game development with ImpactJS
- Building RESTful Web Services with Spring 5(Second Edition)
- SSL VPN : Understanding, evaluating and planning secure, web/based remote access
- Building RESTful Web services with Go
- 圖解手機(jī)元器件維修技巧
- Working with Legacy Systems
- 物聯(lián)網(wǎng)場(chǎng)景設(shè)計(jì)與開(kāi)發(fā)(初級(jí))
- 5G技術(shù)核心與增強(qiáng):從R15到R17
- 組網(wǎng)技術(shù)與網(wǎng)絡(luò)管理
- Dart Cookbook
- 圖解物聯(lián)網(wǎng)
- 物聯(lián)網(wǎng),So Easy!
- Microservices Development Cookbook
- 智能物聯(lián)安防視頻技術(shù)基礎(chǔ)與應(yīng)用