0
我有一個CheckListView顯示自定義對象的列表。我試圖實現一個選擇所有/選擇無選項,但列表視圖不會改變。如果點擊實現在CheckListView上選擇全部JavaFX
複選框只改變pendingUsers_listView.setCellFactory(new Callback<ListView<User>, javafx.scene.control.ListCell<User>>() {
@Override
public ListCell<User> call(ListView<User> listView) {
return new PendingUserCell();
}
});
定製手機:
public class PendingUserCell extends CheckBoxListCell<User> {
PendingUserCell() {
this.setSelectedStateCallback(new Callback<User, ObservableValue<Boolean>>() {
@Override
public ObservableValue<Boolean> call(User param) {
return new SimpleBooleanProperty(param.isApproved());
}
});
}
@Override
public void updateItem(User u, boolean empty) {
super.updateItem(u, empty);
if (empty) {
this.setText(null);
} else {
this.setText(u.getFullName() + " (" + u.getEmail() + ")");
}
}
}
這些負責的行動
public void handleSelectAll() {
this.pendingUsers_listView.getCheckModel().checkAll();
this.pendingUsers_listView.refresh();
}
public void handleSelectNone() {
this.pendingUsers_listView.getCheckModel().clearChecks();
this.pendingUsers_listView.refresh();
}