if (obj.equals(selected))
if ((obj == null && selected == null) || (obj != null &&obj.equals(selected)))
    public int getSelectedIndex() {        Object selected = dataModel.getSelectedItem();        int i,c;        Object obj;        for (i=0, c=dataModel.getSize(); i<c; i++) {            obj = dataModel.getElementAt(i);            if (obj.equals(selected))                return i;        }        return -1;    }