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

Inconsistancies with the DefaultComboBoxModel and the DefaultListModel construct

    XMLWordPrintable

    Details

      Description

      A DESCRIPTION OF THE REQUEST :
      The DefaultComboBoxModel has a constructor that will accept an array or a vector to populate the model with data.

      The DefaultListModel does not. Instead the JList itself has the constructor which accepts an array or a Vector.

      For consistancy, shouldn't DefaultComboBoxModel and DefaultListModel both accept an array or a Vector in the constructor?

      Also, both models would benefit from an addAll(Collection<? extends E> c) method which will all the contents of a Collection without having to iterate through the collection one element at a time.

      JUSTIFICATION :
      For consistancy

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The JList constructor should not accept a Vector to populate the list, the DefaultListModel should.


      ACTUAL -
      The JList constructor currently accepts a Vector.

      ---------- BEGIN SOURCE ----------
      DefaultListModel model = new DefaultListModel();

      for(int i=0;i<v.size();i++) {
        model.addElement(v.elementAt(i));
      }

      JList jList = new JList(model);
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      same as above.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              jssunw Jitender S (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Imported:
                Indexed: