我正在使用GridPane来显示用户输入的结果。
在GridPane中,它有两列,分别是标签的VBox和值的VBox。标签和值为文本。
这是我创建GridPane的方式。
Text textLabel = new Text(label);
Text textValue = new Text(value);
VBox labelVbox = new VBox(textLabel);
VBox valueVbox = new VBox(textValue);
gridPane.add(labelVbox, 0, rowIndex);
gridPane.add(valueVbox, 1, rowIndex);
那些GridPane包含两列多于一行。如何获取每一行的textValue的Text值?
您听说过javadoc吗?
GridPane
的父类具有方法getChildren()
,该方法返回包含的节点的列表。
遍历列表,并为每个孩子得到其文本。
根据您发布的代码,您只希望第1列(一)中的节点,因此可以使用方法getChildren()
仅过滤出与您相关的子节点。类似于:
getColumnIndex()