Accessing a TableRow's style data in a TableVi

2019-06-11 03:55发布

I'm trying to write some TestFX code that will loop through a TableView component and check the background colour for each row is set correctly.

What I can't work out is how to actually construct the loop to go through the TableRows as opposed to the actual data. I've tried using sourceTable.getItems() but that just gives me access to the object containing the data. But I need to go lower down than that and actually examine the background-colour of the CSS tag.

I know that a TableRow has a getStyle function, which will return the data I'm looking for, but I'm at a loss at how to construct the appropriate iteration that will go through each individual row.

标签: javafx testfx
1条回答
一夜七次
2楼-- · 2019-06-11 04:18

My first thought is to use queryAccessibleAttribute() method.. but unfortunately it is not working working as expected. May be someone can correct me.

for (int i=0;i<tableView.getItems().size();i++){
    TableRow row = (TableRow) tableView.queryAccessibleAttribute(AccessibleAttribute.ROW_AT_INDEX,i);
}

So as of now use lookup() for the rendered tablerows.

Set<Node> tableRows = tableView.lookupAll("TableRow");
查看更多
登录 后发表回答