示例#1
0
 @Override
 public void removeNotify() {
   toolkit.lockAWT();
   try {
     super.removeNotify();
     updatePrefWidth();
   } finally {
     toolkit.unlockAWT();
   }
 }
示例#2
0
 @Override
 public void addNotify() {
   toolkit.lockAWT();
   try {
     super.addNotify();
     updatePrefWidth();
     updateIncrements();
   } finally {
     toolkit.unlockAWT();
   }
 }
示例#3
0
 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();
   }
 }
示例#4
0
 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();
   }
 }
示例#5
0
 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();
   }
 }