Adding borders to GridPane JavaFX

后端 未结 3 1575
别跟我提以往
别跟我提以往 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:54

    I apologize for the response instead of the comment, not enough reputation.

    Strangely, but @James_D 's response didn't help me; when the window was resized, the cell borders randomly changed their width, overlapping each other.

    This answer helped solve the problem, so by slightly changing the code given by @James_D (only the .css file), we get:

    .classes-grid {
        -fx-background-color: white ;
        -fx-padding: 10 ;
    }
    .classes-grid-cell {
        -fx-border-color: dimgray;
        -fx-border-width: 0 1 1 0;
        -fx-background-color: transparent;
    }
    .classes-grid-cell.first-row {
        -fx-border-width: 1 1 1 0 ;
    }
    .classes-grid-cell.first-column {
        -fx-border-width: 0 1 1 1 ;
    }
    .classes-grid-cell.first-row.first-column {
        -fx-border-width: 1 ;
    }
    

提交回复
热议问题