我正在用JavaFx应用程序制作Sudoku解算器。我已经准备好网格,如下所示,但是我不知道如何添加中心边框来区分较小的框。
就像普通的数独游戏一样,我想在较小的盒子之间找到边界。
这是代码:-
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;
}