question: private void buildMenu ( ) { setVisible ( false ) ; removeAll ( ) ; if ( recentSearches . getLength ( ) == 0 ) { JMenuItem noRecent = new JMenuItem ( UIManager . getString ( "SearchField.noRecentsText" ) ) ; noRecent . setEnabled ( false ) ; add ( noRecent ) ; } else { JMenuItem recent = new JMenuItem ( UIManager . getString ( "SearchField.recentsMenuTitle" ) ) ; recent . setEnabled ( false ) ; add ( recent ) ; for ( String searchString : recentSearches . getRecentSearches ( ) ) { JMenuItem mi = new JMenuItem ( searchString ) ; mi . addActionListener ( this ) ; add ( mi ) ; } addSeparator ( ) ; clear = new JMenuItem ( UIManager . getString ( "SearchField.clearRecentsText" ) ) ; clear . addActionListener ( this ) ; add ( clear ) ; } }
target:  Rebuilds the menu according to the recent searches.