I have a ListView that I am working to add a ContextMenu to. I have the ContextMenu working find but have another issue.
My
The problem arises from the line
cell.textProperty().bind(cell.itemProperty().asString());
When the cell is empty, the item will be null, so the binding will (I believe) evaluate to the string "null".
Try something that tests for the cell being empty or the item being null, e.g.
cell.textProperty().bind(Bindings
.when(cell.emptyProperty())
.then("")
.otherwise(cell.itemProperty().asString()));
or (thanks to @fabian for refining this version)
cell.textProperty().bind(Bindings.createStringBinding(
() -> Objects.toString(cell.getItem(), ""),
cell.itemProperty()));