JavaFX: Get Node by row and column

Georgi Georgiev

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?

invariant

I don't see any direct API to get node by row column index, but you can use getChildren API from Pane, and getRowIndex(Node child) and 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 the Node using row and column indices from the 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;
            break;
        }
    }

    return result;
}

Important Update: getRowIndex() and getColumnIndex() are now static methods and should be changed to GridPane.getRowIndex(node) and GridPane.getColumnIndex(node).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

JavaFX : How to get column and row index in gridpane?

From Dev

JavaFX : How to get column and row index in gridpane?

From Dev

javafx : get the name of the column

From Dev

get the number row of gridpane Javafx

From Dev

How to get GridPane Row and Column IDs on Mouse Entered in each cell of Grid in JavaFX?

From Dev

Get a value of a row in a column

From Dev

Get real position of a node in JavaFX

From Dev

JavaFX - Get TableView column by name

From Dev

Replace a node at (row,col) in a JavaFX GridPane

From Dev

Suming a specific TableView column/row in JavaFX

From Dev

How to delete row from table column javafx

From Dev

gridpane javafx node column span how to use?

From Dev

gridpane javafx node column span how to use?

From Dev

javafx tableview how to get the row I clicked?

From Dev

jQuery - Get Tallest Column in Row

From Dev

Get visible row and column number

From Dev

Get like value in the row as column?

From Dev

Get screen coordinates of a node in javaFX 8

From Dev

How to get the absolute rotation of a Node in JavaFX

From Dev

Get the height of a node in JavaFX (generate a layout pass)

From Dev

How to get the absolute rotation of a Node in JavaFX

From Dev

SQL query to get column of the next row to be of column of a row and the second row of the column to the next row

From Dev

sql query to get column of the next row to be of column of a row

From Dev

Javafx 2 : How do I delete a row or column in Gridpane

From Dev

Accessing the column and row index of GridPane in JavaFX keeps returning null

From Java

Pandas - Get first row value of a given column

From Dev

Get list from pandas dataframe column or row?

From Dev

Get Values from DataTable by row and column name

From Dev

datatable get specific column from row

Related Related

  1. 1

    JavaFX : How to get column and row index in gridpane?

  2. 2

    JavaFX : How to get column and row index in gridpane?

  3. 3

    javafx : get the name of the column

  4. 4

    get the number row of gridpane Javafx

  5. 5

    How to get GridPane Row and Column IDs on Mouse Entered in each cell of Grid in JavaFX?

  6. 6

    Get a value of a row in a column

  7. 7

    Get real position of a node in JavaFX

  8. 8

    JavaFX - Get TableView column by name

  9. 9

    Replace a node at (row,col) in a JavaFX GridPane

  10. 10

    Suming a specific TableView column/row in JavaFX

  11. 11

    How to delete row from table column javafx

  12. 12

    gridpane javafx node column span how to use?

  13. 13

    gridpane javafx node column span how to use?

  14. 14

    javafx tableview how to get the row I clicked?

  15. 15

    jQuery - Get Tallest Column in Row

  16. 16

    Get visible row and column number

  17. 17

    Get like value in the row as column?

  18. 18

    Get screen coordinates of a node in javaFX 8

  19. 19

    How to get the absolute rotation of a Node in JavaFX

  20. 20

    Get the height of a node in JavaFX (generate a layout pass)

  21. 21

    How to get the absolute rotation of a Node in JavaFX

  22. 22

    SQL query to get column of the next row to be of column of a row and the second row of the column to the next row

  23. 23

    sql query to get column of the next row to be of column of a row

  24. 24

    Javafx 2 : How do I delete a row or column in Gridpane

  25. 25

    Accessing the column and row index of GridPane in JavaFX keeps returning null

  26. 26

    Pandas - Get first row value of a given column

  27. 27

    Get list from pandas dataframe column or row?

  28. 28

    Get Values from DataTable by row and column name

  29. 29

    datatable get specific column from row

HotTag

Archive