JDK-4549174 : RFE: DefaultListModel should have an addAll(Collection c)
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2001-12-06
  • Updated: 2018-01-25
  • Resolved: 2018-01-25
Related Reports
Duplicate :  
Description

Name: rmT116609			Date: 12/05/2001


java version "1.3.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01)
Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)

There is currently no straight forward way of adding a Collection to a DefaultListModel. By checking the
DefaultListModel.java src I found that declaration for addAll() is already there but is commented out.
Since DefaultListModel is backed by a Vector and Vector has addAll() since it is a java.util.List, so
 implementing addAll() would be pretty simple in DefaultListModel. Maybe:
---
int index0 = getSize();
delegate.addAll(c);
int index1 = getSize()
fireIntervalAdded(this, index0, index1);
---
On the longer term DefaultListModel should implement the List interface. Also,
you should consider adding a DefaultSetModel backed by an (optionally sorted)
Set.

If you are going to implement this please try to give an estimate when (or which version).

I've checked the java doc for 1.4beta3 but DefaultListModel were not improve there.
(Review ID: 136795) 
======================================================================