boolean (String filter) { boolean clicked = false; Iterator<Pair<String, JBCheckBox>> iterator = myTriggeredCheckboxes.iterator(); while (iterator.hasNext()) { Pair<String, JBCheckBox> next = iterator.next(); if (next.getFirst().length() < filter.length()) break; iterator.remove(); next.getSecond().doClick(); clicked = true; } return clicked; }