我有以下代码来更新列单元格及其相应行的颜色:
calltypel.setCellFactory(column -> {
return new TableCell<CallLogs, String>() {
@Override
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
setText(empty ? "" : getItem().toString());
setGraphic(null);
TableRow currentRow = getTableRow();
//This doesn't work
if(item.equals("a")){
item.setTextFill(Color.RED);
currentRow.setTextFill(Color.PINK);
}
else{
item.setTextFill(Color.GREEN);
currentRow.setTextFill(Color.BLUE);
}
}
};
});
Run Code Online (Sandbox Code Playgroud)
'if'条件的代码段不起作用.我无法确定对象的正确引用,以及执行此操作的最佳方法是什么.
谢谢!