question: public static void insertIntoCombo ( JComboBox combo , Object item ) { MutableComboBoxModel model = ( MutableComboBoxModel ) combo . getModel ( ) ; if ( model . getSize ( ) == 0 ) { model . insertElementAt ( item , 0 ) ; return ; } Object o = model . getElementAt ( 0 ) ; if ( o . equals ( item ) ) { return ; } model . removeElement ( item ) ; model . insertElementAt ( item , 0 ) ; combo . setSelectedIndex ( 0 ) ; }
target:  Insert the given item into the combo box, and set it as first selected item.  If the item already exists, it is removed, so there are no duplicates.