Answer the question
In order to leave comments, you need to log in
JavaFX. How to make automatic updating of ListView, after operation of change of record in it?
Hello.
I write applications in javafx. Faced the following problem, and I can not understand what I'm doing wrong.
For data storage I use
ObservableList<User> users = new FXCollections.observableArrayList();
// Controller
...
@FXML
private void initialize() {
nameList.setCellFactory((ListView<User> userListView) -> new UsersFormatCell());
}
...
public class UsersFormatCell extends ListCell<User> {
@Override
public void updateItem(User user, boolean empty) {
super.updateItem(user, empty);
// format of the cell in list
setText(user == null ? "" : user.getName());
}
}
Answer the question
In order to leave comments, you need to log in
If I understand your question correctly, then you should try to re-register nameList.setCellFactory() in the method that makes changes to the ListView; same as in initialize
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question