1 回答
TA贡献1828条经验 获得超13个赞
尝试这些方面的东西(例如,我不知道你的“styles.css”在哪里......):
public void start(Stage primaryStage) throws Exception {
GridPane chessTable = new GridPane();
chessTable.getStylesheets().add(getClass().getResource("/styles.css").toString());
for (int h = 0; h < 8; h++) {
for (int w = 0; w < 8; w++) {
Box chessBox = new Box(112, 94, 0);
chessBox.getStyleClass().add("chess-box");
GridPane.setConstraints(chessBox, w, h);
chessTable.getChildren().add(chessBox);
}
}
请注意,它会为代码对面的每个单元格创建一个新框,它会尝试同时将同一个框放入不同的单元格中(只能添加一次)。
添加回答
举报
