if (selectedItem != null && (dataModel instanceof DefaultComboBoxModel))
if (selectedItem != null) {  if(dataModel instanceof DefaultComboBoxModel) {
  public int getSelectedIndex()  {    Object selectedItem = getSelectedItem();    if (selectedItem != null && (dataModel instanceof DefaultComboBoxModel))      return ((DefaultComboBoxModel) dataModel).getIndexOf(selectedItem);    return -1;  }