I set up the gridpane like so:
for (int row = 0; row < mainBoard.getRows(); row++){
for (int column = 0; column < mainBoard.getColumns(); column++) {
mainBoard.setStatusArray(row, column, 0);
Pane pane = new Pane();
GridPane.setRowIndex(pane, row);
GridPane.setColumnIndex(pane, column);
gridpane.getChildren().add(new Pane());
System.out.println(GridPane.getRowIndex(pane));
}
}
And try to access it like so:
ObservableList<Node> childrens = gridpane.getChildren();
for (Node node : childrens) {
if (node instanceof Pane
&& GridPane.getRowIndex(node) == 1 <------------- line of error
&& getColumnIndex(node) == 1) {
// Do stuff
}
}
It seems that GridPane.getRowIndex(node)
Always returns null
, thus causing a NullPointerException
and I cant figure out for the life of me why.