我想为所有第一个孩子设置顶部边框,以便一个孩子的数据在一行中显示。但我无法为这些行设置 id。我尝试了以下代码,但没有帮助。
final PseudoClass firstRowClass = PseudoClass.getPseudoClass("first-child");
devWorkTabBenchtable.setRowFactory(new Callback<TreeTableView<DevWorkTabBench>, TreeTableRow<DevWorkTabBench>>() {
@Override
public TreeTableRow<DevWorkTabBench> call(TreeTableView<DevWorkTabBench> param) {
TreeTableRow<DevWorkTabBench> row = new TreeTableRow<>();
row.treeItemProperty().addListener(new ChangeListener<TreeItem<DevWorkTabBench>>() {
int i = 0;
@Override
public void changed(ObservableValue<? extends TreeItem<DevWorkTabBench>> observable, TreeItem<DevWorkTabBench> oldValue, TreeItem<DevWorkTabBench> newValue) {
if (i < param.getRoot().getChildren().size()) {
row.pseudoClassStateChanged(firstRowClass, newValue == param.getRoot().getChildren().get(i));
}
i++;
}
});
return row;
}
});
我应该使用什么?请指导我。