Is there a way to color only some cells with a specific value of a TableView
?
Callback<TableColumn, TableCell> historyTableCellFactory
= new Callback<TableColumn, TableCell>() {
public TableCell call(TableColumn p) {
TableCell newCell = new TableCell<CustomerHistoryStructure, String>() {
private Text newText;
@Override
public void updateItem(String items, boolean empty) {
super.updateItem(items, empty);
if (!isEmpty()) {
newText = new Text(items.toString());
newText.setWrappingWidth(140);
this.setStyle("-fx-background-color:#e50000 ;");
setGraphic(newText);
}
}
private String getString() {
return getItem() == null ? "" : getItem().toString();
}
};
return newCell;
}
};
The problem with the above code is that when the program is running and I scroll on the TableView
, other cells get colored on their own.