Accessing a TableRow's style data in a TableView

↘锁芯ラ 提交于 2019-12-12 10:23:00

问题


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.


回答1:


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");


来源:https://stackoverflow.com/questions/52630608/accessing-a-tablerows-style-data-in-a-tableview

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!