I am making a Sudoku Solver in a JavaFx Application. I have got the grid ready as shown below, but I don't know how to add the center border to distinguish between the smaller boxes.
Like in a normal sudoku, I want to get the border between the smaller boxes.
Here's is the code:-
private GridPane getGridPane() {
GridPane gridPane = new GridPane();
gridPane.setGridLinesVisible(true);
gridPane.setPadding(new Insets(10));
gridPane.setHgap(0);
gridPane.setHgap(0);
for (int i = 0; i < 9; i++)
for (int j = 0; j < 9; j++) {
buttons[i][j] = new Label("");
buttons[i][j].setStyle("-fx-font-weight: bold; -fx-font-size: 40");
buttons[i][j].setAlignment(Pos.CENTER);
buttons[i][j].setTextAlignment(TextAlignment.CENTER);
buttons[i][j].setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
}
...
for (int i = 0; i < 9; i++) for (int j = 0; j < 9; j++) GridPane.setConstraints(buttons[i][j], j, i);
for (int i = 0; i < 9; i++)
for (int j = 0; j < 9; j++) gridPane.getChildren().add(buttons[i][j]);
GridPane.setHalignment(gridPane, HPos.CENTER);
GridPane.setValignment(gridPane, VPos.CENTER);
gridPane.setAlignment(Pos.CENTER);
return gridPane;
}
Aucun commentaire:
Enregistrer un commentaire