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);
}

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 ) ; }
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 .
