public void insert(Component component,int index){
  if (index < 0) {
    throw new IllegalArgumentException("index less than zero.");
  }
  int nitems=getComponentCount();
  Vector<Component> tempItems=new Vector<Component>();
  for (int i=index; i < nitems; i++) {
    tempItems.addElement(getComponent(index));
    remove(index);
  }
  add(component);
  for (  Component tempItem : tempItems) {
    add(tempItem);
  }
}

public void insert ( Component component , int index ) { if ( index < 0 ) { throw new IllegalArgumentException ( "index less than zero." ) ; } int nitems = getComponentCount ( ) ; Vector < Component > tempItems = new Vector < Component > ( ) ; for ( int i = index ; i < nitems ; i ++ ) { tempItems . addElement ( getComponent ( index ) ) ; remove ( index ) ; } add ( component ) ; for ( Component tempItem : tempItems ) { add ( tempItem ) ; } }
inserts the specified component into the menu at a given position .
