be.ugent.caagt.swirl.lists

Class ArrayListModel<E>

Implemented Interfaces:
List, ListModel, TypedListModel<E>

public class ArrayListModel<E>
extends ArrayList
implements TypedListModel<E>

Implementation of javax.swing.ListModel that behaves like an ArrayList and implements the interface java.util.List from the collections API.

Constructor Summary

ArrayListModel()
Constructs an empty list with an initial capacity of ten.
ArrayListModel(E> c)
Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator.
ArrayListModel(int initialCapacity)
Constructs an empty list with the specified initial capacity.

Method Summary

boolean
add(E o)
void
add(int index, E element)
boolean
addAll(E> c)
boolean
addAll(int index, E> c)
void
addListDataListener(ListDataListener l)
void
clear()
protected void
fireContentsChanged(Object source, int index0, int index1)
Called after one or more elements of the list change.
protected void
fireIntervalAdded(Object source, int index0, int index1)
Called after one or more elements are added to the model.
protected void
fireIntervalRemoved(Object source, int index0, int index1)
Called after one or more elements are removed from the model.
Object
getElementAt(int index)
int
getSize()
boolean
remove(Object obj)
E
remove(int index)
void
removeListDataListener(ListDataListener l)
protected void
removeRange(int fromIndex, int toIndex)
E
set(int index, E element)

Constructor Details

ArrayListModel

public ArrayListModel()
Constructs an empty list with an initial capacity of ten.

ArrayListModel

public ArrayListModel(E> c)
Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator. The ArrayListModel instance has an initial capacity of 110% the size of the specified collection.
Parameters:
c - the collection whose elements are to be placed into this list.

ArrayListModel

public ArrayListModel(int initialCapacity)
Constructs an empty list with the specified initial capacity.

Method Details

add

public boolean add(E o)

add

public void add(int index,
                E element)

addAll

public boolean addAll(E> c)

addAll

public boolean addAll(int index,
                      E> c)

addListDataListener

public void addListDataListener(ListDataListener l)

clear

public void clear()

fireContentsChanged

protected void fireContentsChanged(Object source,
                                   int index0,
                                   int index1)
Called after one or more elements of the list change. The changed elements are specified by the closed interval index0, index1 (endpoints included). Note that index0 need not be less than or equal to index1.
Parameters:
source - the ArrayListModel that changed, typically "this"
index0 - one end of the interval
index1 - the other end of the interval
See Also:
AbstractListModel

fireIntervalAdded

protected void fireIntervalAdded(Object source,
                                 int index0,
                                 int index1)
Called after one or more elements are added to the model. The new elements are specified by a closed interval index0, index1 (endpoints included). Note that index0 need not be less than or equal to index1.
Parameters:
source - the ArrayListModel that changed, typically "this"
index0 - one end of the new interval
index1 - the other end of the new interval
See Also:
AbstractListModel

fireIntervalRemoved

protected void fireIntervalRemoved(Object source,
                                   int index0,
                                   int index1)
Called after one or more elements are removed from the model. index0 and index1 are the end points of the interval that's been removed. Note that index0 need not be less than or equal to index1.
Parameters:
source - the ArrayListModel that changed, typically "this"
index0 - one end of the removed interval, including index0
index1 - the other end of the removed interval, including index1
See Also:
AbstractListModel

getElementAt

public Object getElementAt(int index)

getSize

public int getSize()

remove

public boolean remove(Object obj)

remove

public E remove(int index)

removeListDataListener

public void removeListDataListener(ListDataListener l)

removeRange

protected void removeRange(int fromIndex,
                           int toIndex)

set

public E set(int index,
             E element)