question: public void add ( JMenuItemRecentFile jmirfNew ) { int index = findRecentFile ( jmirfNew . getFile ( ) ) ; if ( index == 0 ) { return ; } removeAllRecentFiles ( ) ; jmirfNew . setPosition ( 1 ) ; if ( index != - 1 ) { for ( int i = 0 ; i <= index ; i ++ ) { JMenuItemRecentFile jmirfTmp = jmiRecentFiles [ i ] ; jmiRecentFiles [ i ] = jmirfNew ; jmirfNew = jmirfTmp ; jmirfNew . setPosition ( i + 2 ) ; } } else { for ( int i = 0 ; i < jmiRecentFiles . length ; i ++ ) { JMenuItemRecentFile jmirfTmp = jmiRecentFiles [ i ] ; jmiRecentFiles [ i ] = jmirfNew ; jmirfNew = jmirfTmp ; if ( jmirfNew == null ) { break ; } jmirfNew . setPosition ( i + 2 ) ; } } addAllRecentFiles ( ) ; }
target:  Add a recent file menu item to the menu. Only call when the menu is completely populated with standard menu items and separators.