JDK-6340040 : Inconsistancies with the DefaultComboBoxModel and the DefaultListModel construct
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-10-21
  • Updated: 2017-05-23
Related Reports
Relates :  
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.

Comments
EVALUATION Agreed. The collection classes bug is 4304287.
26-10-2005

EVALUATION We should unify this when we look at adding collections to the Swing classes.
21-10-2005