I have defined a grid pane in a java fxml file as follows:
<GridPane fx:id="grid" gridLinesVisible="true" prefHeight="256" prefWidth="256">
...
<children>
<Label maxHeight="1.8" maxWidth="1.8" />
<Label maxHeight="1.8" maxWidth="1.8" GridPane.columnIndex="1" />
<Label maxHeight="1.8" maxWidth="1.8" GridPane.columnIndex="2" />
<Label maxHeight="1.8" maxWidth="1.8" GridPane.rowIndex="1" />
<Label maxHeight="1.8" maxWidth="1.8" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Label maxHeight="1.8" maxWidth="1.8" GridPane.columnIndex="2" GridPane.rowIndex="1" />
<Label maxHeight="1.8" maxWidth="1.8" GridPane.rowIndex="2" />
<Label maxHeight="1.8" maxWidth="1.8" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<Label maxHeight="1.8" maxWidth="1.8" GridPane.columnIndex="2" GridPane.rowIndex="2" />
</children>
...
</GridPane>
The grid is 3 x 3 and has a label in each of its cells. Is it possible to loop through the grid and change the text for each label as shown in the pseudo code below:
for (cell : grid)
{
cell.label.setText("x");
}