Hi so I have tried many solutions online on how to get the Node(cell) that was clicked on in the Gridpane. The method I went with for getting the node is shown below. I have also tried iterating through all the nodes prior to this method. I have built the gridpane with scenebuilder and as you can see in the picture below the columns and row are clearly there. I am trying this solution How to get GridPane Row and Column IDs on Mouse Entered in each cell of Grid in JavaFX? however as I've mentioned above the values returned from the rows and columns are null.
@FXML
private void mouseEntered(MouseEvent e) {
Node source = (Node)e.getSource() ;
System.out.println(source);
Integer colIndex = userSelectionGrid.getColumnIndex(source);
Integer rowIndex = userSelectionGrid.getRowIndex(source);
if (colIndex == null && rowIndex == null) System.out.println("BOO");
else
System.out.printf("Mouse entered cell [%d, %d]%n", colIndex.intValue(), rowIndex.intValue());
}
FXML containing this grid
<GridPane fx:id="userSelectionGrid" onMouseClicked="#mouseEntered" prefHeight="44.0" prefWidth="563.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label text="SAVE" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="0">
<font>
<Font name="System Bold" size="13.0" />
</font>
</Label>
<Label text="CANCEL" GridPane.columnIndex="0" GridPane.halignment="CENTER" GridPane.rowIndex="0">
<font>
<Font name="System Bold" size="13.0" />
</font>
</Label>
<Separator orientation="VERTICAL" GridPane.columnIndex="1" />
</children>
<VBox.margin>
<Insets />
</VBox.margin>
</GridPane>