There is object with SimpleBooleanProperty hided field, cell factory, and context menu, one of menuitems sets this property to true.
Question: how to filter/hide this item?
class Element {
val hided = SimpleBooleanProperty(false)
}
class MyController {
@FXML
private lateinit var pckList: ListView<Element>
fun initialize() {
pckList.setCellFactory { _ ->
object : ListCell<Element>() {
init {
contextMenu = ContextMenu(
MenuItem("Hide this packet").apply { setOnAction { item.hided.set(true) } },
)
managedProperty().bind(visibleProperty())
}
override fun updateItem(item: Element?, empty: Boolean) {
super.updateItem(item, empty)
if (item == null) {
graphic = null
return
}
graphic = Label("blahblahblah")
}
}
}
}
}
I tried to setVisible(false), it hides the content, but leaves empty gap between neighbour items...