void () { if (myResult != null) { //noinspection unchecked myComboBox.setModel(new DefaultComboBoxModel(ArrayUtil.toObjectArray(myResult))); final T extra = getExtraItem(); if (extra != null) { myComboBox.insertItemAt(extra, 0); } // ensure that selected ItemEvent will be fired, even if first item of the model // is the same as the next selected myComboBox.setSelectedItem(null); final T selected = getSelectedItem(); if (selected != null) { if (!selected.equals(extra) && !myResult.contains(selected)) { if (addSelectedItemIfMissing()) { myComboBox.addItem(selected); myComboBox.setSelectedItem(selected); } else { selectFirstItem(); } } else { myComboBox.setSelectedItem(selected); } } else { selectFirstItem(); } } else { handleError(); } }