Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6431595

Make DefaultComboBoxModel consistent - enhancement request

XMLWordPrintable

      A DESCRIPTION OF THE REQUEST :
      The methods in DefaultComboBoxModel are somewhat inconsistent in the type of argument & result that they provide.

      Some of the methods use the Object as their argument or result (setSelectedItem, getSelectedItem), some use the index (in particular, insertElementAt), and some have both (remove...). I suggest that both types of argument/result be provided, so that there is also setSelectedIndex, getSelectedIndex (which are in JComboBox for some reason).


      JUSTIFICATION :
      Where the model holds Objects rather than just Strings, setting up temporary Objects to search on is wearisome.

      This also makes for inefficient coding, as it means that one has to do a linear search (with lots of calls to equals()) to find the relevant index. I admit that this isn't too bad, as combo boxes don't usually have very many elements. But it's a nuisance and is a candidate for cleaning up.


      CUSTOMER SUBMITTED WORKAROUND :
      Do a linear search on the model, looking for the relevant object.

            Unassigned Unassigned
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: