This is the scenario:
I have a listView filled with 'Koe' objects, in the listView the 'Koe' objects are listed by their LabID property.
public class Koe {
private final SimpleIntegerProperty koeID = new SimpleIntegerProperty();
private final SimpleStringProperty labID = new SimpleStringProperty("");
...
//GETTERS
public int getKoeID(){
return koeID.get();
}
public String getLabID(){
return labID.get();
}
...
//SETTERS
public void setKoeID(int iKoeID) {
koeID.set(iKoeID);
}
public void setLabID(String sLabID){
labID.set(sLabID);
}
...
@Override
public String toString(){
return "" + labID.get();
}
Now, once a Koe is selected, the Koe's data is loaded in another pane where users can edit it and press a Save button. When the Save button is pressed, the values from the TextFields are saved to the Koe object.
...
k.setLabID(txtLabID.getText());
...
The problem is however that when a user edited the LabID of a Koe object, the ListView does not show the new LabID in the ListView until the ListView being refreshed (As a test, I tried adding a dummy Koe object when users hit the Save button to force a refresh, then it seemed to work).
I did some reading about it and I understand that the ListView should be linked to a SimpleStringProperty object. But, when the users hit the Save button, the setLabID() method updates the Koe's LabID (which is a SimpleStringProperty object)? Does this has something to do with the toString() method? As this is being used to show the Koe's labID in the listView? But then again, this toString() method is linked to the labID SimpleStringProperty?
As you can see, i'm a bit confused. Although, everything works, it's just the problem with the refreshing of the ListView that I haven't been able to solve yet.