I\'m learning JavaFX and i wanted to create a cell factory which is working properly until i want to delete a row from my ListView
:
According to the Java doc of Cell updateItem method, there is slightly different recomended usage than the accepted one:
protected void updateItem(T item, boolean empty) {
super.updateItem(item, empty);
if (empty || item == null) {
setText(null);
setGraphic(null);
} else {
setText(item.toString());
}
}
The difference is in the usage of parameter empty
. But the sollution from @Adam should work correctly in major cases too.