JavaFX 佈局 TilePane

TilePane

子組件會保持同樣大小

TilePane root = new TilePane();
root.setAlignment(Pos.CENTER_LEFT);
root.setHgap(10);
root.setVgap(10);
root.setOrientation(Orientation.HORIZONTAL);
root.setTileAlignment(Pos.TOP_LEFT);

for (int i = 0; i < 5; i++) {
    StackPane stackPane = new StackPane();
    stackPane.setPrefWidth(80 - 10 * i);
    stackPane.setPrefHeight(50);
    stackPane.setStyle("-fx-background-color: #088");
    root.getChildren().add(stackPane);
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章