I updated my code to show how the whole class look like
Still I got some errors can you validate what I need to improve to have it working
Mainly the problem is with fillTableView() method
private TableCell fillTableView() {
clientColumn.setCellFactory(column -> {
return new TableCell() {
@Override
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
setText(empty ? "" : getItem().toString());
setGraphic(null);
TableRow currentRow = getTableRow();
if (!isEmpty()) {
if (item.equals("EMPTY EMPTY"))
currentRow.setStyle("-fx-background-color:green");
else
currentRow.setStyle("-fx-background-color:blue");
}
}
};
});
}
解决方案
You need to update the items of Table View by overriding updateItem() method.
The code is :
yourColumnBased.setCellFactory(column -> {
return new TableCell() {
@Override
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
setText(empty ? "" : getItem().toString());
setGraphic(null);
TableRow currentRow = getTableRow();
if (!isEmpty()) {
if(item.equals("assigned"))
currentRow.setStyle("-fx-background-color:blue");
else
currentRow.setStyle("-fx-background-color:green");
}
}
};
});