Georgi Georgiev Georgi Georgiev - 1 month ago 10x
Java Question

JavaFX: Get Node by row and column

Is there any way to get a specific Node from a gridPane if I know its location (row and column) or any other way to get a node from a gridPane?


I don't see any direct API to get node by row column index,but you can use getChilderen API from Pane ,and getRowIndex(Node child),getColumnIndex(Node child) from GridPane

//Gets the list of children of this Parent. 
public ObservableList<Node> getChildren() 
//Returns the child's column index constraint if set
public static java.lang.Integer getColumnIndex(Node child)
//Returns the child's row index constraint if set.
public static java.lang.Integer getRowIndex(Node child)

here is the sample code to get Node using row ,column index from gridpane

public Node getNodeByRowColumnIndex (final int row, final int column, GridPane gridPane) {
    Node result = null;
    ObservableList<Node> childrens = gridPane.getChildren();

    for (Node node : childrens) {
        if(gridPane.getRowIndex(node) == row && gridPane.getColumnIndex(node) == column) {
            result = node;

    return result;