0
私の目標は、サイズ変更可能な、常に正方形で、同じ数の行と列を含むGridViewを作成して、ReversiまたはChessボードに似たセルを正方形にします。正方形セルの四角形グリッド
ここには小さな図があります。グリッドはコンテンツペインの中央に水平に配置されています。
私は、異なる結合変異体およびレイアウトを多数試みたが、私はかなりそれが権利を取得することはできません。
public class Controller {
public HBox contentPane;
public void initialize() {
final int sideLength = 10;
final GridPane gridPane = new GridPane();
gridPane.setStyle("-fx-border-color: red; -fx-border-insets: 2");
HBox.setHgrow(gridPane, Priority.ALWAYS);
for (int i = 0; i < sideLength; i++) {
final ColumnConstraints columnConstraints = new ColumnConstraints(Control.USE_PREF_SIZE, 10, Double.MAX_VALUE);
columnConstraints.setHgrow(Priority.ALWAYS);
gridPane.getColumnConstraints()
.add(columnConstraints);
final RowConstraints rowConstraints = new RowConstraints(Control.USE_PREF_SIZE, 10, Double.MAX_VALUE);
rowConstraints.setVgrow(Priority.ALWAYS);
gridPane.getRowConstraints()
.add(rowConstraints);
}
contentPane.getChildren().add(gridPane);
for (int i = 0; i < sideLength; i++) {
for (int j = 0; j < sideLength; j++) {
final GameCell child = new GameCell();
GridPane.setRowIndex(child, i);
GridPane.setColumnIndex(child, j);
gridPane.getChildren().add(child);
}
}
}
}
や形状のlatesを含めることになっている細胞、が、私は今ちょうどそれをテストするためには、Sましたが、Circle
:ここに私のコントローラは(今のところ)だ
これは、それが現在どのように見えるか: