javax.swing
Class DefaultListModel

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.swing.AbstractListModel sample code for javax.swing.AbstractListModel definition code for javax.swing.AbstractListModel 
      extended by javax.swing.DefaultListModel
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable , ListModel sample code for javax.swing.ListModel definition code for javax.swing.ListModel

public class DefaultListModel
extends AbstractListModel sample code for javax.swing.AbstractListModel definition code for javax.swing.AbstractListModel

This class loosely implements the java.util.Vector API, in that it implements the 1.1.x version of java.util.Vector, has no collection class support, and notifies the ListDataListeners when changes occur. Presently it delegates to a Vector, in a future release it will be a real Collection implementation.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see XMLEncoder sample code for java.beans.XMLEncoder definition code for java.beans.XMLEncoder .

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractListModel sample code for javax.swing.AbstractListModel definition code for javax.swing.AbstractListModel
listenerList sample code for javax.swing.AbstractListModel.listenerList definition code for javax.swing.AbstractListModel.listenerList
 
Constructor Summary
DefaultListModel sample code for javax.swing.DefaultListModel.DefaultListModel() definition code for javax.swing.DefaultListModel.DefaultListModel() ()
           
 
Method Summary
 void add sample code for javax.swing.DefaultListModel.add(int, java.lang.Object) definition code for javax.swing.DefaultListModel.add(int, java.lang.Object) (int index, Object sample code for java.lang.Object definition code for java.lang.Object  element)
          Inserts the specified element at the specified position in this list.
 void addElement sample code for javax.swing.DefaultListModel.addElement(java.lang.Object) definition code for javax.swing.DefaultListModel.addElement(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  obj)
          Adds the specified component to the end of this list.
 int capacity sample code for javax.swing.DefaultListModel.capacity() definition code for javax.swing.DefaultListModel.capacity() ()
          Returns the current capacity of this list.
 void clear sample code for javax.swing.DefaultListModel.clear() definition code for javax.swing.DefaultListModel.clear() ()
          Removes all of the elements from this list.
 boolean contains sample code for javax.swing.DefaultListModel.contains(java.lang.Object) definition code for javax.swing.DefaultListModel.contains(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  elem)
          Tests whether the specified object is a component in this list.
 void copyInto sample code for javax.swing.DefaultListModel.copyInto(java.lang.Object[]) definition code for javax.swing.DefaultListModel.copyInto(java.lang.Object[]) (Object sample code for java.lang.Object definition code for java.lang.Object [] anArray)
          Copies the components of this list into the specified array.
 Object sample code for java.lang.Object definition code for java.lang.Object elementAt sample code for javax.swing.DefaultListModel.elementAt(int) definition code for javax.swing.DefaultListModel.elementAt(int) (int index)
          Returns the component at the specified index.
 Enumeration sample code for java.util.Enumeration definition code for java.util.Enumeration <?> elements sample code for javax.swing.DefaultListModel.elements() definition code for javax.swing.DefaultListModel.elements() ()
          Returns an enumeration of the components of this list.
 void ensureCapacity sample code for javax.swing.DefaultListModel.ensureCapacity(int) definition code for javax.swing.DefaultListModel.ensureCapacity(int) (int minCapacity)
          Increases the capacity of this list, if necessary, to ensure that it can hold at least the number of components specified by the minimum capacity argument.
 Object sample code for java.lang.Object definition code for java.lang.Object firstElement sample code for javax.swing.DefaultListModel.firstElement() definition code for javax.swing.DefaultListModel.firstElement() ()
          Returns the first component of this list.
 Object sample code for java.lang.Object definition code for java.lang.Object get sample code for javax.swing.DefaultListModel.get(int) definition code for javax.swing.DefaultListModel.get(int) (int index)
          Returns the element at the specified position in this list.
 Object sample code for java.lang.Object definition code for java.lang.Object getElementAt sample code for javax.swing.DefaultListModel.getElementAt(int) definition code for javax.swing.DefaultListModel.getElementAt(int) (int index)
          Returns the component at the specified index.
 int getSize sample code for javax.swing.DefaultListModel.getSize() definition code for javax.swing.DefaultListModel.getSize() ()
          Returns the number of components in this list.
 int indexOf sample code for javax.swing.DefaultListModel.indexOf(java.lang.Object) definition code for javax.swing.DefaultListModel.indexOf(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  elem)
          Searches for the first occurrence of elem.
 int indexOf sample code for javax.swing.DefaultListModel.indexOf(java.lang.Object, int) definition code for javax.swing.DefaultListModel.indexOf(java.lang.Object, int) (Object sample code for java.lang.Object definition code for java.lang.Object  elem, int index)
          Searches for the first occurrence of elem, beginning the search at index.
 void insertElementAt sample code for javax.swing.DefaultListModel.insertElementAt(java.lang.Object, int) definition code for javax.swing.DefaultListModel.insertElementAt(java.lang.Object, int) (Object sample code for java.lang.Object definition code for java.lang.Object  obj, int index)
          Inserts the specified object as a component in this list at the specified index.
 boolean isEmpty sample code for javax.swing.DefaultListModel.isEmpty() definition code for javax.swing.DefaultListModel.isEmpty() ()
          Tests whether this list has any components.
 Object sample code for java.lang.Object definition code for java.lang.Object lastElement sample code for javax.swing.DefaultListModel.lastElement() definition code for javax.swing.DefaultListModel.lastElement() ()
          Returns the last component of the list.
 int lastIndexOf sample code for javax.swing.DefaultListModel.lastIndexOf(java.lang.Object) definition code for javax.swing.DefaultListModel.lastIndexOf(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  elem)
          Returns the index of the last occurrence of elem.
 int lastIndexOf sample code for javax.swing.DefaultListModel.lastIndexOf(java.lang.Object, int) definition code for javax.swing.DefaultListModel.lastIndexOf(java.lang.Object, int) (Object sample code for java.lang.Object definition code for java.lang.Object  elem, int index)
          Searches backwards for elem, starting from the specified index, and returns an index to it.
 Object sample code for java.lang.Object definition code for java.lang.Object remove sample code for javax.swing.DefaultListModel.remove(int) definition code for javax.swing.DefaultListModel.remove(int) (int index)
          Removes the element at the specified position in this list.
 void removeAllElements sample code for javax.swing.DefaultListModel.removeAllElements() definition code for javax.swing.DefaultListModel.removeAllElements() ()
          Removes all components from this list and sets its size to zero.
 boolean removeElement sample code for javax.swing.DefaultListModel.removeElement(java.lang.Object) definition code for javax.swing.DefaultListModel.removeElement(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  obj)
          Removes the first (lowest-indexed) occurrence of the argument from this list.
 void removeElementAt sample code for javax.swing.DefaultListModel.removeElementAt(int) definition code for javax.swing.DefaultListModel.removeElementAt(int) (int index)
          Deletes the component at the specified index.
 void removeRange sample code for javax.swing.DefaultListModel.removeRange(int, int) definition code for javax.swing.DefaultListModel.removeRange(int, int) (int fromIndex, int toIndex)
          Deletes the components at the specified range of indexes.
 Object sample code for java.lang.Object definition code for java.lang.Object set sample code for javax.swing.DefaultListModel.set(int, java.lang.Object) definition code for javax.swing.DefaultListModel.set(int, java.lang.Object) (int index, Object sample code for java.lang.Object definition code for java.lang.Object  element)
          Replaces the element at the specified position in this list with the specified element.
 void setElementAt sample code for javax.swing.DefaultListModel.setElementAt(java.lang.Object, int) definition code for javax.swing.DefaultListModel.setElementAt(java.lang.Object, int) (Object sample code for java.lang.Object definition code for java.lang.Object  obj, int index)
          Sets the component at the specified index of this list to be the specified object.
 void setSize sample code for javax.swing.DefaultListModel.setSize(int) definition code for javax.swing.DefaultListModel.setSize(int) (int newSize)
          Sets the size of this list.
 int size sample code for javax.swing.DefaultListModel.size() definition code for javax.swing.DefaultListModel.size() ()
          Returns the number of components in this list.
 Object sample code for java.lang.Object definition code for java.lang.Object [] toArray sample code for javax.swing.DefaultListModel.toArray() definition code for javax.swing.DefaultListModel.toArray() ()
          Returns an array containing all of the elements in this list in the correct order.
 String sample code for java.lang.String definition code for java.lang.String toString sample code for javax.swing.DefaultListModel.toString() definition code for javax.swing.DefaultListModel.toString() ()
          Returns a string that displays and identifies this object's properties.
 void trimToSize sample code for javax.swing.DefaultListModel.trimToSize() definition code for javax.swing.DefaultListModel.trimToSize() ()
          Trims the capacity of this list to be the list's current size.
 
Methods inherited from class javax.swing.AbstractListModel sample code for javax.swing.AbstractListModel definition code for javax.swing.AbstractListModel
addListDataListener sample code for javax.swing.AbstractListModel.addListDataListener(javax.swing.event.ListDataListener) definition code for javax.swing.AbstractListModel.addListDataListener(javax.swing.event.ListDataListener) , fireContentsChanged sample code for javax.swing.AbstractListModel.fireContentsChanged(java.lang.Object, int, int) definition code for javax.swing.AbstractListModel.fireContentsChanged(java.lang.Object, int, int) , fireIntervalAdded sample code for javax.swing.AbstractListModel.fireIntervalAdded(java.lang.Object, int, int) definition code for javax.swing.AbstractListModel.fireIntervalAdded(java.lang.Object, int, int) , fireIntervalRemoved sample code for javax.swing.AbstractListModel.fireIntervalRemoved(java.lang.Object, int, int) definition code for javax.swing.AbstractListModel.fireIntervalRemoved(java.lang.Object, int, int) , getListDataListeners sample code for javax.swing.AbstractListModel.getListDataListeners() definition code for javax.swing.AbstractListModel.getListDataListeners() , getListeners sample code for javax.swing.AbstractListModel.getListeners(java.lang.Class) definition code for javax.swing.AbstractListModel.getListeners(java.lang.Class) , removeListDataListener sample code for javax.swing.AbstractListModel.removeListDataListener(javax.swing.event.ListDataListener) definition code for javax.swing.AbstractListModel.removeListDataListener(javax.swing.event.ListDataListener)
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

DefaultListModel sample code for javax.swing.DefaultListModel() definition code for javax.swing.DefaultListModel()

public DefaultListModel()
Method Detail

getSize sample code for javax.swing.DefaultListModel.getSize() definition code for javax.swing.DefaultListModel.getSize()

public int getSize()
Returns the number of components in this list.

This method is identical to size, which implements the List interface defined in the 1.2 Collections framework. This method exists in conjunction with setSize so that size is identifiable as a JavaBean property.

Returns:
the number of components in this list
See Also:
size() sample code for javax.swing.DefaultListModel.size() definition code for javax.swing.DefaultListModel.size()

getElementAt sample code for javax.swing.DefaultListModel.getElementAt(int) definition code for javax.swing.DefaultListModel.getElementAt(int)

public Object sample code for java.lang.Object definition code for java.lang.Object  getElementAt(int index)
Returns the component at the specified index.
Note: Although this method is not deprecated, the preferred method to use is get(int), which implements the List interface defined in the 1.2 Collections framework.

Parameters:
index - an index into this list
Returns:
the component at the specified index
Throws:
ArrayIndexOutOfBoundsException sample code for java.lang.ArrayIndexOutOfBoundsException definition code for java.lang.ArrayIndexOutOfBoundsException - if the index is negative or greater than the current size of this list
See Also:
get(int) sample code for javax.swing.DefaultListModel.get(int) definition code for javax.swing.DefaultListModel.get(int)

copyInto sample code for javax.swing.DefaultListModel.copyInto(java.lang.Object[]) definition code for javax.swing.DefaultListModel.copyInto(java.lang.Object[])

public void copyInto(Object sample code for java.lang.Object definition code for java.lang.Object [] anArray)
Copies the components of this list into the specified array. The array must be big enough to hold all the objects in this list, else an IndexOutOfBoundsException is thrown.

Parameters:
anArray - the array into which the components get copied
See Also:
Vector.copyInto(Object[]) sample code for java.util.Vector.copyInto(java.lang.Object[]) definition code for java.util.Vector.copyInto(java.lang.Object[])

trimToSize sample code for javax.swing.DefaultListModel.trimToSize() definition code for javax.swing.DefaultListModel.trimToSize()

public void trimToSize()
Trims the capacity of this list to be the list's current size.

See Also:
Vector.trimToSize() sample code for java.util.Vector.trimToSize() definition code for java.util.Vector.trimToSize()

ensureCapacity sample code for javax.swing.DefaultListModel.ensureCapacity(int) definition code for javax.swing.DefaultListModel.ensureCapacity(int)

public void ensureCapacity(int minCapacity)
Increases the capacity of this list, if necessary, to ensure that it can hold at least the number of components specified by the minimum capacity argument.

Parameters:
minCapacity - the desired minimum capacity
See Also:
Vector.ensureCapacity(int) sample code for java.util.Vector.ensureCapacity(int) definition code for java.util.Vector.ensureCapacity(int)

setSize sample code for javax.swing.DefaultListModel.setSize(int) definition code for javax.swing.DefaultListModel.setSize(int)

public void setSize(int newSize)
Sets the size of this list.

Parameters:
newSize - the new size of this list
See Also:
Vector.setSize(int) sample code for java.util.Vector.setSize(int) definition code for java.util.Vector.setSize(int)

capacity sample code for javax.swing.DefaultListModel.capacity() definition code for javax.swing.DefaultListModel.capacity()

public int capacity()
Returns the current capacity of this list.

Returns:
the current capacity
See Also:
Vector.capacity() sample code for java.util.Vector.capacity() definition code for java.util.Vector.capacity()

size sample code for javax.swing.DefaultListModel.size() definition code for javax.swing.DefaultListModel.size()

public int size()
Returns the number of components in this list.

Returns:
the number of components in this list
See Also:
Vector.size() sample code for java.util.Vector.size() definition code for java.util.Vector.size()

isEmpty sample code for javax.swing.DefaultListModel.isEmpty() definition code for javax.swing.DefaultListModel.isEmpty()

public boolean isEmpty()
Tests whether this list has any components.

Returns:
true if and only if this list has no components, that is, its size is zero; false otherwise
See Also:
Vector.isEmpty() sample code for java.util.Vector.isEmpty() definition code for java.util.Vector.isEmpty()

elements sample code for javax.swing.DefaultListModel.elements() definition code for javax.swing.DefaultListModel.elements()

public Enumeration sample code for java.util.Enumeration definition code for java.util.Enumeration <?> elements()
Returns an enumeration of the components of this list.

Returns:
an enumeration of the components of this list
See Also:
Vector.elements() sample code for java.util.Vector.elements() definition code for java.util.Vector.elements()

contains sample code for javax.swing.DefaultListModel.contains(java.lang.Object) definition code for javax.swing.DefaultListModel.contains(java.lang.Object)

public boolean contains(Object sample code for java.lang.Object definition code for java.lang.Object  elem)
Tests whether the specified object is a component in this list.

Parameters:
elem - an object
Returns:
true if the specified object is the same as a component in this list
See Also:
Vector.contains(Object) sample code for java.util.Vector.contains(java.lang.Object) definition code for java.util.Vector.contains(java.lang.Object)

indexOf sample code for javax.swing.DefaultListModel.indexOf(java.lang.Object) definition code for javax.swing.DefaultListModel.indexOf(java.lang.Object)

public int indexOf(Object sample code for java.lang.Object definition code for java.lang.Object  elem)
Searches for the first occurrence of elem.

Parameters:
elem - an object
Returns:
the index of the first occurrence of the argument in this list; returns -1 if the object is not found
See Also:
Vector.indexOf(Object) sample code for java.util.Vector.indexOf(java.lang.Object) definition code for java.util.Vector.indexOf(java.lang.Object)

indexOf sample code for javax.swing.DefaultListModel.indexOf(java.lang.Object, int) definition code for javax.swing.DefaultListModel.indexOf(java.lang.Object, int)

public int indexOf(Object sample code for java.lang.Object definition code for java.lang.Object  elem,
                   int index)
Searches for the first occurrence of elem, beginning the search at index.

Parameters:
elem - an desired component
index - the index from which to begin searching
Returns:
the index where the first occurrence of elem is found after index; returns -1 if the elem is not found in the list
See Also:
Vector.indexOf(Object,int) sample code for java.util.Vector.indexOf(java.lang.Object, int) definition code for java.util.Vector.indexOf(java.lang.Object, int)

lastIndexOf sample code for javax.swing.DefaultListModel.lastIndexOf(java.lang.Object) definition code for javax.swing.DefaultListModel.lastIndexOf(java.lang.Object)

public int lastIndexOf(Object sample code for java.lang.Object definition code for java.lang.Object  elem)
Returns the index of the last occurrence of elem.

Parameters:
elem - the desired component
Returns:
the index of the last occurrence of elem in the list; returns -1 if the object is not found
See Also:
Vector.lastIndexOf(Object) sample code for java.util.Vector.lastIndexOf(java.lang.Object) definition code for java.util.Vector.lastIndexOf(java.lang.Object)

lastIndexOf sample code for javax.swing.DefaultListModel.lastIndexOf(java.lang.Object, int) definition code for javax.swing.DefaultListModel.lastIndexOf(java.lang.Object, int)

public int lastIndexOf(Object sample code for java.lang.Object definition code for java.lang.Object  elem,
                       int index)
Searches backwards for elem, starting from the specified index, and returns an index to it.

Parameters:
elem - the desired component
index - the index to start searching from
Returns:
the index of the last occurrence of the elem in this list at position less than index; returns -1 if the object is not found
See Also:
Vector.lastIndexOf(Object,int) sample code for java.util.Vector.lastIndexOf(java.lang.Object, int) definition code for java.util.Vector.lastIndexOf(java.lang.Object, int)

elementAt sample code for javax.swing.DefaultListModel.elementAt(int) definition code for javax.swing.DefaultListModel.elementAt(int)

public Object sample code for java.lang.Object definition code for java.lang.Object  elementAt(int index)
Returns the component at the specified index. Throws an ArrayIndexOutOfBoundsException if the index is negative or not less than the size of the list.
Note: Although this method is not deprecated, the preferred method to use is get(int), which implements the List interface defined in the 1.2 Collections framework.

Parameters:
index - an index into this list
Returns:
the component at the specified index
See Also:
get(int) sample code for javax.swing.DefaultListModel.get(int) definition code for javax.swing.DefaultListModel.get(int) , Vector.elementAt(int) sample code for java.util.Vector.elementAt(int) definition code for java.util.Vector.elementAt(int)

firstElement sample code for javax.swing.DefaultListModel.firstElement() definition code for javax.swing.DefaultListModel.firstElement()

public Object sample code for java.lang.Object definition code for java.lang.Object  firstElement()
Returns the first component of this list. Throws a NoSuchElementException if this vector has no components.

Returns:
the first component of this list
See Also:
Vector.firstElement() sample code for java.util.Vector.firstElement() definition code for java.util.Vector.firstElement()

lastElement sample code for javax.swing.DefaultListModel.lastElement() definition code for javax.swing.DefaultListModel.lastElement()

public Object sample code for java.lang.Object definition code for java.lang.Object  lastElement()
Returns the last component of the list. Throws a NoSuchElementException if this vector has no components.

Returns:
the last component of the list
See Also:
Vector.lastElement() sample code for java.util.Vector.lastElement() definition code for java.util.Vector.lastElement()

setElementAt sample code for javax.swing.DefaultListModel.setElementAt(java.lang.Object, int) definition code for javax.swing.DefaultListModel.setElementAt(java.lang.Object, int)

public void setElementAt(Object sample code for java.lang.Object definition code for java.lang.Object  obj,
                         int index)
Sets the component at the specified index of this list to be the specified object. The previous component at that position is discarded.

Throws an ArrayIndexOutOfBoundsException if the index is invalid.

Note: Although this method is not deprecated, the preferred method to use is set(int,Object), which implements the List interface defined in the 1.2 Collections framework.

Parameters:
obj - what the component is to be set to
index - the specified index
See Also:
set(int,Object) sample code for javax.swing.DefaultListModel.set(int, java.lang.Object) definition code for javax.swing.DefaultListModel.set(int, java.lang.Object) , Vector.setElementAt(Object,int) sample code for java.util.Vector.setElementAt(E, int) definition code for java.util.Vector.setElementAt(E, int)

removeElementAt sample code for javax.swing.DefaultListModel.removeElementAt(int) definition code for javax.swing.DefaultListModel.removeElementAt(int)

public void removeElementAt(int index)
Deletes the component at the specified index.

Throws an ArrayIndexOutOfBoundsException if the index is invalid.

Note: Although this method is not deprecated, the preferred method to use is remove(int), which implements the List interface defined in the 1.2 Collections framework.

Parameters:
index - the index of the object to remove
See Also:
remove(int) sample code for javax.swing.DefaultListModel.remove(int) definition code for javax.swing.DefaultListModel.remove(int) , Vector.removeElementAt(int) sample code for java.util.Vector.removeElementAt(int) definition code for java.util.Vector.removeElementAt(int)

insertElementAt sample code for javax.swing.DefaultListModel.insertElementAt(java.lang.Object, int) definition code for javax.swing.DefaultListModel.insertElementAt(java.lang.Object, int)

public void insertElementAt(Object sample code for java.lang.Object definition code for java.lang.Object  obj,
                            int index)
Inserts the specified object as a component in this list at the specified index.

Throws an ArrayIndexOutOfBoundsException if the index is invalid.

Note: Although this method is not deprecated, the preferred method to use is add(int,Object), which implements the List interface defined in the 1.2 Collections framework.

Parameters:
obj - the component to insert
index - where to insert the new component
Throws:
ArrayIndexOutOfBoundsException sample code for java.lang.ArrayIndexOutOfBoundsException definition code for java.lang.ArrayIndexOutOfBoundsException - if the index was invalid
See Also:
add(int,Object) sample code for javax.swing.DefaultListModel.add(int, java.lang.Object) definition code for javax.swing.DefaultListModel.add(int, java.lang.Object) , Vector.insertElementAt(Object,int) sample code for java.util.Vector.insertElementAt(E, int) definition code for java.util.Vector.insertElementAt(E, int)

addElement sample code for javax.swing.DefaultListModel.addElement(java.lang.Object) definition code for javax.swing.DefaultListModel.addElement(java.lang.Object)

public void addElement(Object sample code for java.lang.Object definition code for java.lang.Object  obj)
Adds the specified component to the end of this list.

Parameters:
obj - the component to be added
See Also:
Vector.addElement(Object) sample code for java.util.Vector.addElement(E) definition code for java.util.Vector.addElement(E)

removeElement sample code for javax.swing.DefaultListModel.removeElement(java.lang.Object) definition code for javax.swing.DefaultListModel.removeElement(java.lang.Object)

public boolean removeElement(Object sample code for java.lang.Object definition code for java.lang.Object  obj)
Removes the first (lowest-indexed) occurrence of the argument from this list.

Parameters:
obj - the component to be removed
Returns:
true if the argument was a component of this list; false otherwise
See Also:
Vector.removeElement(Object) sample code for java.util.Vector.removeElement(java.lang.Object) definition code for java.util.Vector.removeElement(java.lang.Object)

removeAllElements sample code for javax.swing.DefaultListModel.removeAllElements() definition code for javax.swing.DefaultListModel.removeAllElements()

public void removeAllElements()
Removes all components from this list and sets its size to zero.
Note: Although this method is not deprecated, the preferred method to use is clear, which implements the List interface defined in the 1.2 Collections framework.

See Also:
clear() sample code for javax.swing.DefaultListModel.clear() definition code for javax.swing.DefaultListModel.clear() , Vector.removeAllElements() sample code for java.util.Vector.removeAllElements() definition code for java.util.Vector.removeAllElements()

toString sample code for javax.swing.DefaultListModel.toString() definition code for javax.swing.DefaultListModel.toString()

public String sample code for java.lang.String definition code for java.lang.String  toString()
Returns a string that displays and identifies this object's properties.

Overrides:
toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
a String representation of this object

toArray sample code for javax.swing.DefaultListModel.toArray() definition code for javax.swing.DefaultListModel.toArray()

public Object sample code for java.lang.Object definition code for java.lang.Object [] toArray()
Returns an array containing all of the elements in this list in the correct order.

Returns:
an array containing the elements of the list
See Also:
Vector.toArray() sample code for java.util.Vector.toArray() definition code for java.util.Vector.toArray()

get sample code for javax.swing.DefaultListModel.get(int) definition code for javax.swing.DefaultListModel.get(int)

public Object sample code for java.lang.Object definition code for java.lang.Object  get(int index)
Returns the element at the specified position in this list.

Throws an ArrayIndexOutOfBoundsException if the index is out of range (index < 0 || index >= size()).

Parameters:
index - index of element to return

set sample code for javax.swing.DefaultListModel.set(int, java.lang.Object) definition code for javax.swing.DefaultListModel.set(int, java.lang.Object)

public Object sample code for java.lang.Object definition code for java.lang.Object  set(int index,
                  Object sample code for java.lang.Object definition code for java.lang.Object  element)
Replaces the element at the specified position in this list with the specified element.

Throws an ArrayIndexOutOfBoundsException if the index is out of range (index < 0 || index >= size()).

Parameters:
index - index of element to replace
element - element to be stored at the specified position
Returns:
the element previously at the specified position

add sample code for javax.swing.DefaultListModel.add(int, java.lang.Object) definition code for javax.swing.DefaultListModel.add(int, java.lang.Object)

public void add(int index,
                Object sample code for java.lang.Object definition code for java.lang.Object  element)
Inserts the specified element at the specified position in this list.

Throws an ArrayIndexOutOfBoundsException if the index is out of range (index < 0 || index > size()).

Parameters:
index - index at which the specified element is to be inserted
element - element to be inserted

remove sample code for javax.swing.DefaultListModel.remove(int) definition code for javax.swing.DefaultListModel.remove(int)

public Object sample code for java.lang.Object definition code for java.lang.Object  remove(int index)
Removes the element at the specified position in this list. Returns the element that was removed from the list.

Throws an ArrayIndexOutOfBoundsException if the index is out of range (index < 0 || index >= size()).

Parameters:
index - the index of the element to removed

clear sample code for javax.swing.DefaultListModel.clear() definition code for javax.swing.DefaultListModel.clear()

public void clear()
Removes all of the elements from this list. The list will be empty after this call returns (unless it throws an exception).


removeRange sample code for javax.swing.DefaultListModel.removeRange(int, int) definition code for javax.swing.DefaultListModel.removeRange(int, int)

public void removeRange(int fromIndex,
                        int toIndex)
Deletes the components at the specified range of indexes. The removal is inclusive, so specifying a range of (1,5) removes the component at index 1 and the component at index 5, as well as all components in between.

Throws an ArrayIndexOutOfBoundsException if the index was invalid. Throws an IllegalArgumentException if fromIndex > toIndex.

Parameters:
fromIndex - the index of the lower end of the range
toIndex - the index of the upper end of the range
See Also:
remove(int) sample code for javax.swing.DefaultListModel.remove(int) definition code for javax.swing.DefaultListModel.remove(int)