I am in troubles... I have a JavaFX Tableview tha cointain, in a column, some results. These results can be "OK", "N/A" and "KO" and if i have an "OK" i paint it in green, if i have a "N/A" i paint in black,if i have a "KO" i paint it in red (all by method setStyle()). The problem is that when i slide the table vertically the colour of the text change randomly and i have "OK" in red or "KO" in green... I think i should use something like repaint() but JavaFX hasn't it, so how can i do? The code about the results:
for (ResultMatch result : events) {
isMatch = (result.match().equals("OK") || result.match().equals("N/A"));
//Set the style
reader.getSampleController().xmlMatch.setCellFactory(new Callback<TableColumn<String, String>, TableCell<String, String>>() {
@Override
public TableCell call(TableColumn p) {
return new TableCell<String, String>() {
@Override
public void updateItem(final String item, final boolean empty) {
super.updateItem(item, empty);
if (item != null) {
setText(item);
setAlignment(Pos.CENTER);
switch (item) {
case "OK":
getStyleClass().remove("koItem");
getStyleClass().remove("naItem");
getStyleClass().add("okItem");
break;
case "N/A":
getStyleClass().remove("okItem");
getStyleClass().remove("koItem");
getStyleClass().add("naItem");
break;
case "KO":
getStyleClass().remove("okItem");
getStyleClass().remove("naItem");
getStyleClass().add("koItem");
break;
default:
setStyle("");
break;
}
} else {
setText(null);
}
}
};
}
});
isPass = isPass && isMatch;
reader.getSampleController().getViewXML().getItems().add(result);
}