void () { final Object selectedItem = myProfilesComboBox.getSelectedItem(); reloadCopyrightProfiles(); myProfilesComboBox.setSelectedItem(selectedItem); final ArrayList<ScopeSetting> toRemove = new ArrayList<>(); for (ScopeSetting setting : myScopeMappingModel.getItems()) { if (setting.getProfile() == null) { toRemove.add(setting); } } for (ScopeSetting setting : toRemove) { myScopeMappingModel.removeRow(myScopeMappingModel.indexOf(setting)); } }