public void addItem(String item,int i){
  int oldMaxLength=maxLength;
  boolean hsbWasVis=hsbVis;
  boolean vsbWasVis=vsbVis;
  int addedIndex=0;
  if (i < 0 || i >= items.size()) {
    i=-1;
  }
  currentIndex=-1;
  if (i == -1) {
    items.addElement(item);
    i=0;
    addedIndex=items.size() - 1;
  }
 else {
    items.insertElementAt(item,i);
    addedIndex=i;
    for (int j=0; j < selected.length; j++) {
      if (selected[j] >= i) {
        selected[j]+=1;
      }
    }
  }
  if (log.isLoggable(PlatformLogger.Level.FINER)) {
    log.finer("Adding item '" + item + "' to "+ addedIndex);
  }
  boolean repaintItems=!isItemHidden(addedIndex);
  maxLength=Math.max(maxLength,getItemWidth(addedIndex));
  layout();
  int options=0;
  if (vsbVis != vsbWasVis || hsbVis != hsbWasVis) {
    options=PAINT_ALL;
  }
 else {
    options=(repaintItems ? (PAINT_ITEMS) : 0) | ((maxLength != oldMaxLength || (hsbWasVis ^ hsbVis)) ? (PAINT_HSCROLL) : 0) | ((vsb.needsRepaint()) ? (PAINT_VSCROLL) : 0);
  }
  if (log.isLoggable(PlatformLogger.Level.FINEST)) {
    log.finest("Last visible: " + getLastVisibleItem() + ", hsb changed : "+ (hsbWasVis ^ hsbVis)+ ", items changed "+ repaintItems);
  }
  repaint(addedIndex,getLastVisibleItem(),options);
}

public void addItem ( String item , int i ) { int oldMaxLength = maxLength ; boolean hsbWasVis = hsbVis ; boolean vsbWasVis = vsbVis ; int addedIndex = 0 ; if ( i < 0 || i >= items . size ( ) ) { i = - 1 ; } currentIndex = - 1 ; if ( i == - 1 ) { items . addElement ( item ) ; i = 0 ; addedIndex = items . size ( ) - 1 ; } else { items . insertElementAt ( item , i ) ; addedIndex = i ; for ( int j = 0 ; j < selected . length ; j ++ ) { if ( selected [ j ] >= i ) { selected [ j ] += 1 ; } } } if ( log . isLoggable ( PlatformLogger . Level . FINER ) ) { log . finer ( "Adding item '" + item + "' to " + addedIndex ) ; } boolean repaintItems = ! isItemHidden ( addedIndex ) ; maxLength = Math . max ( maxLength , getItemWidth ( addedIndex ) ) ; layout ( ) ; int options = 0 ; if ( vsbVis != vsbWasVis || hsbVis != hsbWasVis ) { options = PAINT_ALL ; } else { options = ( repaintItems ? ( PAINT_ITEMS ) : 0 ) | ( ( maxLength != oldMaxLength || ( hsbWasVis ^ hsbVis ) ) ? ( PAINT_HSCROLL ) : 0 ) | ( ( vsb . needsRepaint ( ) ) ? ( PAINT_VSCROLL ) : 0 ) ; } if ( log . isLoggable ( PlatformLogger . Level . FINEST ) ) { log . finest ( "Last visible: " + getLastVisibleItem ( ) + ", hsb changed : " + ( hsbWasVis ^ hsbVis ) + ", items changed " + repaintItems ) ; } repaint ( addedIndex , getLastVisibleItem ( ) , options ) ; }
add an item if the index of the item is < 0 or > = than items . size ( ) then add the item to the end of the list
