java - How to detect whether the user has selected an item on a ListView? -
i have listview
items in it, , go next page, user must select item, because next page modifying selected item.
to go next page, user clicks button labeled "next". have grayed out default, i'd un-grayed moment user clicks on element in listview
.
at moment, have set on onmouseclick
isn't effective because activates quite literally whenever listview
node clicked, not when element is.
how solve this?
you can check original tutorial, section "processing list item selection" (example 11-5).
listview.getselectionmodel().selecteditemproperty().addlistener((obs, oldval, newval) -> { // newval contains selected item });
also can bind disableproperty
of button
selecteditemproperty
of selection model of listview
conditionally:
nextbutton.disableproperty().bind(listview.getselectionmodel().selecteditemproperty().isnull());
Comments
Post a Comment