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; }   public void addItem(Object object) { checkMutableComboBoxModel(); ((MutableComboBoxModel)dataModel).addElement(object); }
    public void setSelectedIndex(int index) {        int size = dataModel.getSize();        if (index == -1 )            setSelectedItem( null );        else if (index < -1 || index >= size) {            throw new IllegalArgumentException("setSelectedIndex: " + index + " out of bounds");        else            setSelectedItem(dataModel.getElementAt(index));    }    /**     * Returns the index of the currently selected item in the list.     *     * @return the selected item in the list or -1 if no item is selected or if     *         the currently selected item (text field) is not in the list     */    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;    }    /**      * Adds an item to the item list.     * This method works only if the SComboBox uses the default data model.     * SComboBox uses the default data model when created with the      * empty constructor and no other model has been set.     *     * @param object the Object to add to the list     */    public void addItem(Object object) {        checkMutableComboBoxModel();        ((MutableComboBoxModel)dataModel).addElement(object);    }