I would like to have an action performed when I select an item from my listview in javafx 2.
I use a Netbeans JavaFX fxml application and SceneBuilder.
The OnMouseClicked method in SceneBuilder did not work. It gave me back an error that it can’t find the method that I have already declared.
Can someone tell me how they managed to get it to work?
You cannot do it in FXML file alone.
Define the corresponding listView (assuming
fx:id="myListView"in FXML) in Controller class of the FXML file:Add listener in init/start method which will listen to the list view item changes:
MyDataModelcan be your own data structure model class or simply aString.For String example,