@Override public void removeNotify() { toolkit.lockAWT(); try { super.removeNotify(); updatePrefWidth(); } finally { toolkit.unlockAWT(); } }
@Override public void addNotify() { toolkit.lockAWT(); try { super.addNotify(); updatePrefWidth(); updateIncrements(); } finally { toolkit.unlockAWT(); } }
public void replaceItem(String newValue, int index) { toolkit.lockAWT(); try { items.set(index, newValue); updatePrefWidth(); doRepaint(); } catch (IndexOutOfBoundsException e) { throw new ArrayIndexOutOfBoundsException(e.getMessage()); } finally { toolkit.unlockAWT(); } }
public void add(String item, int index) { toolkit.lockAWT(); try { String str = (item != null ? item : ""); // $NON-NLS-1$ int pos = index; int size = items.size(); if ((pos < 0) || (pos > size)) { pos = size; } items.add(pos, str); updatePrefWidth(); doRepaint(); } finally { toolkit.unlockAWT(); } }
public void remove(int position) { toolkit.lockAWT(); try { selection.remove(new Integer(position)); items.remove(position); // decrease all selected indices greater than position // by 1, because items list is shifted to the left for (int i = 0; i < selection.size(); i++) { Integer idx = selection.get(i); int val = idx.intValue(); if (val > position) { selection.set(i, new Integer(val - 1)); } } updatePrefWidth(); doRepaint(); } catch (IndexOutOfBoundsException e) { throw new ArrayIndexOutOfBoundsException(e.getMessage()); } finally { toolkit.unlockAWT(); } }