How to bind the position in a List to an attribute of that element?
问题 I have an ObservableList<MyElement> list = FXCollections.observableArrayList(); public class MyElement { private IntegerProperty position;//with getter //[...] //somewhere in the constructor taking the list as argument position.bind(list.indexOf(this)); } Now I'd like to bind MyElement.position to the actual position in the list i.e. if the position changes in the list (for instance drag and drop in the GUI or anything else) I want the position property to be updated automatically. Is this