I tried to get the row/column index of gridpane, when I click.
I am looking for method like as getSelectedColumn() in JTable(java swing)
I searched this. gri
As @Roland points out, you can also assign a listener to each node. When doing so you can use a single callback method with this approach (mouse-pressed handler as example, but works with others too):
Assigning the handler to the nodes. Let's assume you have an array of buttons:
for (Button button : buttons) {
button.setOnMousePressed(this::onPress);
}
Mouse pressed handler method:
void onPress(MouseEvent event) {
int column = GridPane.getColumnIndex((Node) event.getSource());
int row = GridPane.getRowIndex((Node) event.getSource());
System.out.println(String.format("Node clicked at: column=%d, row=%d", column, row));
}