/** * Selects the specified objects from the list and keep all previous selections. * * @param objects the objects to be selected */ public void addCheckBoxListSelectedValues(Object[] objects) { if (objects != null) { Map<Object, String> map = new HashMap<Object, String>(); for (Object o : objects) { map.put(o, ""); } int i, c; ListModel model = getModel(); boolean changed = false; for (i = 0, c = model.getSize(); i < c; i++) if (map.get(model.getElementAt(i)) != null) { addCheckBoxListSelectedIndex(i); changed = true; } if (changed) { repaint(); } map.clear(); } }
for (i = 0, c = model.getSize(); i < c; i++) if (anObject.equals(model.getElementAt(i))) { addCheckBoxListSelectedIndex(i); if (shouldScroll) ensureIndexIsVisible(i); for (i = 0, c = model.getSize(); i < c; i++) { if (model.getElementAt(i) == null) { addCheckBoxListSelectedIndex(i); if (shouldScroll) ensureIndexIsVisible(i);