I just finished writing a code that open an element after clicking on it on the listView. But I wish to add a feature that allows user to modify that element, so user double clicks on the element to modify and simple clicks it to show his pannel . Any solution for that ? Thank you
Use the setOnMouseClicked
in a custom CellFactory
.
yourListView.setCellFactory(lv -> new ListCell<YourObject>()
{
@Override
public void updateItem(YourObject item, boolean empty)
{
super.updateItem(item, empty);
if (empty) {
setText(null);
setGraphic(null);
}
else {
//do other stuff here
setOnMouseClicked(mouseClickedEvent -> {
if (mouseClickedEvent.getButton().equals(MouseButton.PRIMARY) && mouseClickedEvent.getClickCount() == 2) {
System.out.println("double clicked");
}
});
}
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.