I have the following piece of code to update both the color of a column cell and its corresponding row:
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);
}
}
};
});
The code segment of 'if' condition doesn't work. I am unable to identify the correct references to objects and also what is the best way to do this.
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…