Adding borders to GridPane JavaFX

后端 未结 3 1570
别跟我提以往
别跟我提以往 2020-11-30 15:11

I am creating a board game in JavaFX using GridPane.

There are 7 different animations which could be placed in each grid (cell) of the grid.

Initially the gr

3条回答
  •  执念已碎
    2020-11-30 15:36

    Simply add an H and V gap of one pixel width and let the grid pane's background color "shine" through:

    .my-grid-pane {
        -fx-background-color: lightgray;
        -fx-vgap: 1;
        -fx-hgap: 1;
        -fx-padding: 1;
    }
    

    If the grid pane's background color spreads from outside more than one pixel (will happen if its parent is larger than itself), just wrap the grid in a Group!

提交回复
热议问题