Note that you are trying to do something more complex with cells in a ListView than with cells in a TableView . In TableView objects displayed in the cells changed, so it was easy for the cameras to observe this. In ListView you want cells to notice when properties belonging to the objects displayed in the cells change; this is another step, so you need to do a little extra coding (although not as much as you will see).
You can create a custom factory cell to bind to stepNameProperty() , but it's complicated (you have to disable / remove listeners from old elements in updateItem() ).
An easier way that is poorly documented is to use an ObservableList with a specific extractor.
Correct the method names first: you have some weird inconsistencies in the code you posted. The label names getX / setX / xProperty must match correctly. That is, instead of
public void setName ( ) { stepName.setValue(); } public String getName() { return stepName.getValue(); } public StringProperty stepNameProperty() { return actionStepID; } >
you should have
public final void setName ( ) { stepName.setValue(); } public final getName() { return stepName.getValue(); } public StringProperty nameProperty() { return stepName; } >
and similarly for other resource access methods. (Obviously, the field names can be any way you like, as they are private.) Creating get / set final methods is good practice.
Then create the list using the extractor . An extractor is a function that maps each item in a list to an Observable array that will be displayed in a list. If these values ββchange, they will update the list of updates to the list observers. Since your ActionStep toString() method refers to nameProperty() , I assume that you want the ListView update if nameProperty() changes. So you want to do
listOfSteps = FXCollections.observableArrayList( actionStep - > new Observable [] {actionStep.nameProperty()}// "" ); actionStepsListView.setItems(listOfSteps); >
Note that in earlier versions of JavaFX 2.2, ListView did not honor the list of update events; this was fixed (if I remember correctly) shortly before the release of Java 8. (Since you noted the JavaFX8 question, I assume you are using Java 8, and therefore you should be fine.)
If you are not using Java 8, you can use the following (equivalent, but more verbose) code:
listOfSteps = FXCollections.observableArrayList( Callback < ActionStep, Observable [] >() { @Override Observable [] (ActionStep actionStep) { return new Observable [] {actionStep.nameProperty()}; } }); actionStepListView.setItems(listOfSteps); >