I really have difficulties to understand how the ObservableList object is working in JavaFX. I want to monitor if an object in the List has been modified. So fa
public static void main(String[] args) {
ArrayList intList = new ArrayList();
intList.add(0);
intList.add(1);
ObservableList ob = FXCollections.observableArrayList(intList);
ob.addListener(new ListChangeListener() {
@Override
public void onChanged(javafx.collections.ListChangeListener.Change extends Integer> c) {
System.out.println("Changed on " + c);
if(c.next()){
System.out.println(c.getFrom());
}
}
});
ob.set(0, 1);
}
The event (c in my case) is the index that the change occurred on (when you do .getFrom()). Also if you print the event out you get a string that tells you exactly what happend. You mistakenly interpret it has a change being done on the list as a whole!