javafx GridPane检索特定的Cell内容 [英] javafx GridPane retrieve specific Cell content
本文介绍了javafx GridPane检索特定的Cell内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想检索Gridpane中一个特定单元格的内容。我已将按钮放在单元格中
I want to retrieve the content of one specific cell in a Gridpane. I have put buttons in the cells with the
setConstraints(btt , 0 ,1 )
setConstraints(btt , 0 ,2 )
getChildren().add....
在我的情况下, GridPane.getChildren.get(10)
并不好。我想直接进入单元格(4,2)并获取其内容。
In my case the GridPane.getChildren.get(10)
is not good. I want to go directly to the cell(4,2) and get its content.
推荐答案
我想如果没有从gridpane获取特定节点的解决方案是列和行索引,我有一个函数来做到这一点,
Well I guess if there is no solution to get a specific node from gridpane by is column and row index, I have a function to do that,
private Node getNodeFromGridPane(GridPane gridPane, int col, int row) {
for (Node node : gridPane.getChildren()) {
if (GridPane.getColumnIndex(node) == col && GridPane.getRowIndex(node) == row) {
return node;
}
}
return null;
}
这篇关于javafx GridPane检索特定的Cell内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文