I used Stackoverflow for wrapping the text in a table cell. But when I focus on a table row, the text color does not change anymore. I tried everything.
This is what I have now in my Controller:
colWie.setCellFactory(column -> {
return new TableCell<DraaiboekActie, String>() {
private Text text;
@Override
public void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (!isEmpty()) {
text = new Text(item);
text.wrappingWidthProperty().bind(colWie.widthProperty());
text.getStyleClass().add("coltext");
setGraphic(text);
}
}
};
});
And this is what I have in my css :
.coltext {
-fx-fill: white;
}
.coltext:focused:selected:filled{
-fx-fill: black;
}
You need something like
.table-cell .coltext {
-fx-fill: white ;
}
.table-cell:focused:filled:selected .coltext {
-fx-fill: black ;
}
(I'm assuming coltext
and draaiboektext
are supposed to be the same thing.)