I want to remove TableCells out of my TableView. Therefore I call this line:
table.getItems().remove(item);
The TableCell is removed correctly, but the ToolTip will be shown on the next TableCell. For example: When I remove the first Cell, the ToolTip will be shown on the second Cell (which is now the first). How do I avoid this issue?
My CellFactory looks like that:
column.setCellFactory(c -> {
TableCell<DataItem, DataItem> cell = new TableCell<DataItem, DataItem>() {
@Override
protected void updateItem(DataItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null) {
setText(item.getName());
if (item.getDescription() != null && !item.getDescription().isEmpty()) {
setTooltip(new Tooltip(item.getDescription()));
}
}
}
};
return cell;
});
Handle the case where
item
is null. If you think in terms of "removing data from the table model", instead of "removing cells" (you're not removing any cells at all, you're just changing the data displayed by the existing cells), this should make sense.