public void insert(MenuItem menuitem,int index){
synchronized (getTreeLock()) {
    if (index < 0) {
      throw new IllegalArgumentException("index less than zero.");
    }
    int nitems=getItemCount();
    Vector<MenuItem> tempItems=new Vector<>();
    for (int i=index; i < nitems; i++) {
      tempItems.addElement(getItem(index));
      remove(index);
    }
    add(menuitem);
    for (int i=0; i < tempItems.size(); i++) {
      add(tempItems.elementAt(i));
    }
  }
}

public void insert ( MenuItem menuitem , int index ) { synchronized ( getTreeLock ( ) ) { if ( index < 0 ) { throw new IllegalArgumentException ( "index less than zero." ) ; } int nitems = getItemCount ( ) ; Vector < MenuItem > tempItems = new Vector < > ( ) ; for ( int i = index ; i < nitems ; i ++ ) { tempItems . addElement ( getItem ( index ) ) ; remove ( index ) ; } add ( menuitem ) ; for ( int i = 0 ; i < tempItems . size ( ) ; i ++ ) { add ( tempItems . elementAt ( i ) ) ; } } }
inserts a menu item into this menu at the specified position .
