E - 这个模型的元素的类型 
       public class DefaultListModel<E> extends AbstractListModel<E>
java.util.Vector API,因为它实现了1.1.x版本的java.util.Vector ,没有收集类支持,并在发生更改时通知ListDataListener 。 
       目前它代表一个Vector ,在将来的版本中,它将是一个真正的Collection实现。 
        警告:此类的序列化对象与将来的Swing版本不兼容。 当前的序列化支持适用于运行相同版本的Swing的应用程序之间的短期存储或RMI。 从1.4开始,对所有JavaBeans的长期存储的支持已被添加到java.beans包中。 请参阅XMLEncoder 。 
listenerList| Constructor and Description | 
|---|
| DefaultListModel() | 
| Modifier and Type | Method and Description | 
|---|---|
| void | add(int index, E element)
              在此列表中的指定位置插入指定的元素。 
             | 
| void | addElement(E element)
              将指定的组件添加到此列表的末尾。 
             | 
| int | capacity()
              返回此列表的当前容量。 
             | 
| void | clear()
              从列表中删除所有元素。 
             | 
| boolean | contains(Object elem)
              测试指定的对象是否是此列表中的组件。 
             | 
| void | copyInto(Object[] anArray)
              将此列表的组件复制到指定的数组中。 
             | 
| E | elementAt(int index)
              返回指定索引处的组件。 
             | 
| Enumeration<E> | elements()
              返回此列表的组件的枚举。 
             | 
| void | ensureCapacity(int minCapacity)
              如有必要,增加此列表的容量,以确保它至少能够容纳最小容量参数指定的组件数。 
             | 
| E | firstElement()
              返回此列表的第一个组件。 
             | 
| E | get(int index)
              返回此列表中指定位置的元素。 
             | 
| E | getElementAt(int index)
              返回指定索引处的组件。 
             | 
| int | getSize()
              返回此列表中的组件数。 
             | 
| int | indexOf(Object elem)
              搜索首次发生 
              elem。 | 
| int | indexOf(Object elem, int index)
              搜索首次发生 
              elem,开始搜索index。 | 
| void | insertElementAt(E element, int index)
              在指定的index中将指定的元素作为该列表中的组件 
              index。 | 
| boolean | isEmpty()
              测试此列表是否包含任何组件。 
             | 
| E | lastElement()
              返回列表的最后一个组件。 
             | 
| int | lastIndexOf(Object elem)
              返回上一次发生的指数 
              elem。 | 
| int | lastIndexOf(Object elem, int index)
              向后搜索 
              elem,从指定的索引开始,并返回它的下标。 | 
| E | remove(int index)
              删除该列表中指定位置的元素。 
             | 
| void | removeAllElements()
              从此列表中删除所有组件,并将其大小设置为零。 
             | 
| boolean | removeElement(Object obj)
              从此列表中删除参数的第一个(最低索引)出现次数。 
             | 
| void | removeElementAt(int index)
              删除指定索引处的组件。 
             | 
| void | removeRange(int fromIndex, int toIndex)
              删除指定范围的索引中的组件。 
             | 
| E | set(int index, E element)
              用指定的元素替换此列表中指定位置的元素。 
             | 
| void | setElementAt(E element, int index)
              设置在指定的组件 
              index这个名单的是指定的元素。 | 
| void | setSize(int newSize)
              设置此列表的大小。 
             | 
| int | size()
              返回此列表中的组件数。 
             | 
| Object[] | toArray()
              以正确的顺序返回包含此列表中所有元素的数组。 
             | 
| String | toString()
              返回显示和标识此对象属性的字符串。 
             | 
| void | trimToSize()
              将此列表的容量修改为列表的当前大小。 
             | 
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListenerpublic int getSize()
 此方法是相同的size ,它实现了List在1.2集合框架定义的接口。 此方法存在于与结合setSize使得size是标识为JavaBean属性。 
size() 
           public E getElementAt(int index)
Note: Although this method is not deprecated, the preferred method to use isget(int), which implements theListinterface defined in the 1.2 Collections framework.
index - 这个列表的索引 
           ArrayIndexOutOfBoundsException - 如果 
            index为负数或大于此列表的当前大小 
           get(int) 
           public void copyInto(Object[] anArray)
IndexOutOfBoundsException 。 
          anArray - 组件被复制到的阵列 
           Vector.copyInto(Object[]) 
           public void trimToSize()
Vector.trimToSize() 
           public void ensureCapacity(int minCapacity)
minCapacity - 所需的最小容量 
           Vector.ensureCapacity(int) 
           public void setSize(int newSize)
newSize - 这个列表的新大小 
           Vector.setSize(int) 
           public int capacity()
Vector.capacity() 
           public int size()
Vector.size() 
           public boolean isEmpty()
true当且仅当此列表没有组件时,即其大小为零; 
            false否则 
           Vector.isEmpty() 
           public Enumeration<E> elements()
Vector.elements() 
           public boolean contains(Object elem)
elem - 一个对象 
           true如果指定的对象与此列表中的组件相同 
           Vector.contains(Object) 
           public int indexOf(Object elem)
elem 。 
          elem - 一个对象 
           -1 
           Vector.indexOf(Object) 
           public int indexOf(Object elem, int index)
elem ,开始搜索 
           index 。 
          elem - 所需组件 
           index - 从哪里开始搜索的索引 
           elem被后发现index ; 
            返回-1如果elem没有在列表中找到 
           Vector.indexOf(Object,int) 
           public int lastIndexOf(Object elem)
elem 。 
          elem - 所需组件 
           elem ; 
            如果找不到该对象,则返回-1 
           Vector.lastIndexOf(Object) 
           public int lastIndexOf(Object elem, int index)
elem ,从指定的索引开始,并返回它的下标。 
          elem - 所需组件 
           index - 开始搜索的索引 
           elem在此列表中在位置小于index ; 
            如果没有找到该对象,则返回-1 
           Vector.lastIndexOf(Object,int) 
           public E elementAt(int index)
ArrayIndexOutOfBoundsException 。 
           Note: Although this method is not deprecated, the preferred method to use isget(int), which implements theListinterface defined in the 1.2 Collections framework.
index - 这个列表的索引 
           get(int) , 
            Vector.elementAt(int) 
           public E firstElement()
NoSuchElementException如果此向量没有组件。 
          Vector.firstElement() 
           public E lastElement()
NoSuchElementException如果此向量没有组件。 
          Vector.lastElement() 
           public void setElementAt(E element, int index)
index这个名单的是指定的元素。 
           该位置的上一个组件被丢弃。 
            如果索引无效,则抛出ArrayIndexOutOfBoundsException 。 
Note: Although this method is not deprecated, the preferred method to use isset(int,Object), which implements theListinterface defined in the 1.2 Collections framework.
element - 要设置的组件 
           index - 指定的索引 
           set(int,Object) , 
            Vector.setElementAt(Object,int) 
           public void removeElementAt(int index)
 如果索引无效,则抛出ArrayIndexOutOfBoundsException 。 
Note: Although this method is not deprecated, the preferred method to use isremove(int), which implements theListinterface defined in the 1.2 Collections framework.
index - 要删除的对象的索引 
           remove(int) , 
            Vector.removeElementAt(int) 
           public void insertElementAt(E element, int index)
index 。 
            如果索引无效,则抛出ArrayIndexOutOfBoundsException 。 
Note: Although this method is not deprecated, the preferred method to use isadd(int,Object), which implements theListinterface defined in the 1.2 Collections framework.
element - 要插入的组件 
           index - 在哪里插入新组件 
           ArrayIndexOutOfBoundsException - 如果索引无效 
           add(int,Object) , 
            Vector.insertElementAt(Object,int) 
           public void addElement(E element)
element - 要添加的组件 
           Vector.addElement(Object) 
           public boolean removeElement(Object obj)
obj - 要删除的组件 
           true如果参数是此列表的组件; 
            false否则 
           Vector.removeElement(Object) 
           public void removeAllElements()
Note: Although this method is not deprecated, the preferred method to use isclear, which implements theListinterface defined in the 1.2 Collections framework.
clear() , 
            Vector.removeAllElements() 
           public Object[] toArray()
Vector.toArray() 
           public E get(int index)
 抛出一个ArrayIndexOutOfBoundsException如果索引超出范围( index < 0 || index >= size() )。 
index - 要返回的元素的索引 
           public E set(int index, E element)
 抛出一个ArrayIndexOutOfBoundsException如果索引超出范围( index < 0 || index >= size() )。 
index - 要替换的元素的索引 
           element - 要存储在指定位置的元素 
           public void add(int index,
                E element) 
           抛出一个ArrayIndexOutOfBoundsException如果索引超出范围( index < 0 || index > size() )。 
index - 要插入指定元素的索引 
           element - 要插入的元素 
           public E remove(int index)
 抛出一个ArrayIndexOutOfBoundsException如果索引超出范围( index < 0 || index >= size() )。 
index - 要删除的元素的索引 
           public void clear()
public void removeRange(int fromIndex,
                        int toIndex) 
           如果索引无效,则抛出ArrayIndexOutOfBoundsException 。 抛出一个IllegalArgumentException如果fromIndex > toIndex 。 
fromIndex - 范围下限的指数 
           toIndex - 范围上限的索引 
           remove(int) 
            Submit a bug or feature 
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
 Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.