--- /home/cpdev/src/classpath/javax/swing/JComboBox.java	2005-07-14 05:32:43.000000000 +0000
+++ javax/swing/JComboBox.java	2005-06-30 05:35:09.000000000 +0000
@@ -79,7 +79,7 @@
   private static final long serialVersionUID = 5654585963292734470L;
 
   /**
-   * Classes implementing this interface are
+   * KeySelectionManager interface. Class implementing this interface are
    * responsible for matching key characters typed by the user with combo
    * box's items.
    */
@@ -95,7 +95,7 @@
   private static final int DEFAULT_MAXIMUM_ROW_COUNT = 8;
 
   /**
-   * Data model used by JComboBox to keep track of its list data and currently
+   * dataModel used by JComboBox to keep track of its list data and currently
    * selected element in the list.
    */
   protected ComboBoxModel dataModel;
@@ -290,16 +290,16 @@
    */
   public void setModel(ComboBoxModel newDataModel)
   {
+
     // dataModel is null if it this method is called from inside the constructors.
-    if (dataModel != null)
-      {
-        // Prevents unneccessary updates.
-        if (dataModel == newDataModel)
-          return;
+    if(dataModel != null) {
+	// Prevents unneccessary updates.
+	if (dataModel == newDataModel)
+		return;
 
-        // Removes itself (as DataListener) from the to-be-replaced model.
-        dataModel.removeListDataListener(this);
-      }
+    	// Removes itself (as DataListener) from the to-be-replaced model.
+    	dataModel.removeListDataListener(this);
+    }
     
     /* Adds itself as a DataListener to the new model.
      * It is intentioned that this operation will fail with a NullPointerException if the
@@ -366,8 +366,8 @@
   {
     if (isEditable != editable)
       {
-        isEditable = editable;
-        firePropertyChange("editable", !isEditable, isEditable);
+	isEditable = editable;
+	firePropertyChange("editable", ! isEditable, isEditable);
       }
   }
 
@@ -383,10 +383,10 @@
   {
     if (maximumRowCount != rowCount)
       {
-        int oldMaximumRowCount = maximumRowCount;
-        maximumRowCount = rowCount;
-        firePropertyChange("maximumRowCount", oldMaximumRowCount,
-                           maximumRowCount);
+	int oldMaximumRowCount = maximumRowCount;
+	maximumRowCount = rowCount;
+	firePropertyChange("maximumRowCount",
+	                   oldMaximumRowCount, maximumRowCount);
       }
   }
 
@@ -415,9 +415,10 @@
   {
     if (renderer != aRenderer)
       {
-        ListCellRenderer oldRenderer = renderer;
-        renderer = aRenderer;
-        firePropertyChange("renderer", oldRenderer, renderer);
+	ListCellRenderer oldRenderer = renderer;
+	renderer = aRenderer;
+	firePropertyChange("renderer", oldRenderer,
+	                   renderer);
       }
   }
 
@@ -500,52 +501,52 @@
    */
   public void setSelectedIndex(int index)
   {
-  	if (index < -1 || index >= dataModel.getSize())
-      // Fails because index is out of bounds.
-      throw new IllegalArgumentException("illegal index: " + index);
-    else
-       // Selects the item at the given index or clears the selection if the
-       // index value is -1.
-      setSelectedItem((index == -1) ? null : dataModel.getElementAt(index));
+  	if(index < -1 || index >= dataModel.getSize()) {
+  		// Fails because index is out of bounds. 
+  		throw new IllegalArgumentException("illegal index: " + index);
+  	} else {
+  		/* Selects the item at the given index or clears the selection if the
+  		 * index value is -1.
+  		 */
+		setSelectedItem((index == -1) ? null : dataModel.getElementAt(index));
+  	}
   }
 
   /**
-   * Returns index of the item that is currently selected in the combo box. If
-   * no item is currently selected, then -1 is returned.
-   * <p>
-   * Note: For performance reasons you should minimize invocation of this
-   * method. If the data model is not an instance of
-   * <code>DefaultComboBoxModel</code> the complexity is O(n) where n is the
-   * number of elements in the combo box.
-   * </p>
+   * Returns index of the item that is currently selected  in the combo box.
+   * If no item is currently selected, then -1 is returned.
    * 
-   * @return int Index specifying location of the currently selected item in the
-   *         combo box or -1 if nothing is selected in the combo box.
+   * <p>Note: For performance reasons you should minimize invocation of this
+   * method. If the data model is not an instance of
+   * <code>DefaultComboBoxModel</code> the complexity is O(n) where
+   * n is the number of elements in the combo box.</p>
+   *
+   * @return int Index specifying location of the currently selected item in
+   *         the combo box or -1 if nothing is selected in the combo box.
    */
   public int getSelectedIndex()
   {
     Object selectedItem = getSelectedItem();
-
-    if (selectedItem != null)
-      {
-        if (dataModel instanceof DefaultComboBoxModel)
-          // Uses special method of DefaultComboBoxModel to retrieve the index.
-          return ((DefaultComboBoxModel) dataModel).getIndexOf(selectedItem);
-        else
-          {
-            // Iterates over all items to retrieve the index.
-            int size = dataModel.getSize();
-
-            for (int i = 0; i < size; i++)
-              {
-                Object o = dataModel.getElementAt(i);
-
-                // XXX: Is special handling of ComparableS neccessary?
-                if ((selectedItem != null) ? selectedItem.equals(o) : o == null)
-                  return i;
-              }
-          }
-      }
+    
+    if (selectedItem != null) {
+	
+		if(dataModel instanceof DefaultComboBoxModel) {
+			// Uses special method of DefaultComboBoxModel to retrieve the index.
+        	  	return ((DefaultComboBoxModel) dataModel).getIndexOf(selectedItem);
+		} else {
+			// Iterates over all items to retrieve the index.
+			int size = dataModel.getSize();
+			
+	  		for(int i=0; i < size; i++) {
+	  			Object o = dataModel.getElementAt(i);
+	  			
+				// XXX: Is special handling of ComparableS neccessary?
+	  			if((selectedItem != null) ? selectedItem.equals(o) : o == null) {
+	  				return i;
+	  			}
+	  		}
+		}
+    }
 
     // returns that no item is currently selected
     return -1;
@@ -570,12 +571,11 @@
    */
   public void addItem(Object element)
   {
-  	if (dataModel instanceof MutableComboBoxModel)
-      ((MutableComboBoxModel) dataModel).addElement(element);
-    else
-      throw new RuntimeException("Unable to add the item because the data "
-                                 + "model it is not an instance of "
-                                 + "MutableComboBoxModel.");
+  	if(dataModel instanceof MutableComboBoxModel) {
+		((MutableComboBoxModel) dataModel).addElement(element);
+  	} else {
+  		throw new RuntimeException("Unable to add the item because the data model it is not an instance of MutableComboBoxModel.");
+  	}
   }
 
   /**
@@ -588,12 +588,11 @@
    */
   public void insertItemAt(Object element, int index)
   {
-	if (dataModel instanceof MutableComboBoxModel)
-      ((MutableComboBoxModel) dataModel).insertElementAt(element, index);
-    else
-      throw new RuntimeException("Unable to insert the item because the data "
-                                 + "model it is not an instance of "
-                                 + "MutableComboBoxModel.");
+	if(dataModel instanceof MutableComboBoxModel) {
+		((MutableComboBoxModel) dataModel).insertElementAt(element, index);
+	} else {
+		throw new RuntimeException("Unable to insert the item because the data model it is not an instance of MutableComboBoxModel.");
+	}
   }
 
   /**
@@ -605,12 +604,11 @@
    */
   public void removeItem(Object element)
   {
-	if (dataModel instanceof MutableComboBoxModel)
-      ((MutableComboBoxModel) dataModel).removeElement(element);
-    else
-      throw new RuntimeException("Unable to remove the item because the data "
-                                 + "model it is not an instance of "
-                                 + "MutableComboBoxModel.");
+	if(dataModel instanceof MutableComboBoxModel) {
+		((MutableComboBoxModel) dataModel).removeElement(element);
+	} else {
+		throw new RuntimeException("Unable to remove the item because the data model it is not an instance of MutableComboBoxModel.");
+	}
   }
 
   /**
@@ -623,40 +621,40 @@
    */
   public void removeItemAt(int index)
   {
-    if (dataModel instanceof MutableComboBoxModel)
-      ((MutableComboBoxModel) dataModel).removeElementAt(index);
-    else
-      throw new RuntimeException("Unable to remove the item because the data "
-                                 + "model it is not an instance of "
-                                 + "MutableComboBoxModel.");
+	if(dataModel instanceof MutableComboBoxModel) {
+		((MutableComboBoxModel) dataModel).removeElementAt(index);
+	} else {
+		throw new RuntimeException("Unable to remove the item because the data model it is not an instance of MutableComboBoxModel.");
+	}
   }
 
   /**
    * This method removes all elements from this JComboBox.
-   * <p>
-   * A <code>RuntimeException</code> is thrown if the data model is not an
-   * instance of {@link MutableComboBoxModel}.
-   * </p>
+   * <p>A <code>RuntimeException</code> is thrown if the data model is not
+   * an instance of {@link MutableComboBoxModel}.</p>
+   * 
    */
   public void removeAllItems()
   {
-    if (dataModel instanceof DefaultComboBoxModel)
-      // Uses special method if we have a DefaultComboBoxModel.
-      ((DefaultComboBoxModel) dataModel).removeAllElements();
-    else if (dataModel instanceof MutableComboBoxModel)
-      {
-        // Iterates over all items and removes each.
-        MutableComboBoxModel mcbm = (MutableComboBoxModel) dataModel;
-
-         // We intentionally remove the items backwards to support models which
-         // shift their content to the beginning (e.g. linked lists)
-        for (int i = mcbm.getSize() - 1; i >= 0; i--)
-          mcbm.removeElementAt(i);
-      }
-    else
-      throw new RuntimeException("Unable to remove the items because the data "
-                                 +"model it is not an instance of "
-                                 + "MutableComboBoxModel.");
+    if (dataModel instanceof DefaultComboBoxModel) {
+    	// Uses special method if we have a DefaultComboBoxModel.
+	((DefaultComboBoxModel) dataModel).removeAllElements();
+    } else if(dataModel instanceof MutableComboBoxModel){
+    	// Iterates over all items and removes each.
+    	MutableComboBoxModel mcbm = (MutableComboBoxModel) dataModel;
+
+	/* We intentionally remove the items backwards to support
+	 * models which shift their content to the beginning (e.g.
+	 * linked lists) 
+	 */     	
+    	for(int i=mcbm.getSize()-1; i >= 0; i--) {
+    		mcbm.removeElementAt(i);
+    	}
+    	
+    } else {
+	throw new RuntimeException("Unable to remove the items because the data model it is not an instance of MutableComboBoxModel.");
+    }
+      
   }
 
   /**
@@ -757,13 +755,13 @@
   {
     if (a == null)
       {
-        setEnabled(true);
-        setToolTipText(null);
+	setEnabled(true);
+	setToolTipText(null);
       }
     else
       {
-        setEnabled(a.isEnabled());
-        setToolTipText((String) (a.getValue(Action.SHORT_DESCRIPTION)));
+	setEnabled(a.isEnabled());
+	setToolTipText((String) (a.getValue(Action.SHORT_DESCRIPTION)));
       }
   }
 
@@ -773,18 +771,18 @@
    *
    * @param action action to listen to for property changes
    *
-   * @return a PropertyChangeListener that listens to changes in
+   * @return $PropertyChangeListener$ Listener that listens to changes in
    *         action properties.
    */
   protected PropertyChangeListener createActionPropertyChangeListener(Action action)
   {
     return new PropertyChangeListener()
       {
-        public void propertyChange(PropertyChangeEvent e)
-        {
-          Action act = (Action) (e.getSource());
-          configurePropertiesFromAction(act);
-        }
+	public void propertyChange(PropertyChangeEvent e)
+	{
+	  Action act = (Action) (e.getSource());
+	  configurePropertiesFromAction(act);
+	}
       };
   }
 
@@ -938,8 +936,8 @@
     boolean oldEnabled = super.isEnabled();
     if (enabled != oldEnabled)
       {
-        super.setEnabled(enabled);
-        firePropertyChange("enabled", oldEnabled, enabled);
+	super.setEnabled(enabled);
+	firePropertyChange("enabled", oldEnabled, enabled);
       }
   }
 
