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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -