官术网_书友最值得收藏!

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:

主站蜘蛛池模板: 新乐市| 卫辉市| 台江县| 奉化市| 额济纳旗| 保德县| 定安县| 辽阳市| 孟州市| 嘉峪关市| 壶关县| 海盐县| 开远市| 临清市| 勐海县| 博客| 义乌市| 浙江省| 青岛市| 达州市| 青铜峡市| 高要市| 禹州市| 搜索| 清流县| 柘城县| 鲁甸县| 合水县| 巍山| 塘沽区| 潞西市| 安化县| 浪卡子县| 灵石县| 竹北市| 兴仁县| 梁平县| 尤溪县| 洪雅县| 桂东县| 浮山县|