|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.AbstractSequentialList<E>
java.util.LinkedList<E>
com.jgoodies.binding.list.LinkedListModel<E>
E
- the type of the list elementspublic final class LinkedListModel<E>
Adds ListModel
capabilities to its superclass
LinkedList
, i. e. allows to observe changes in the content and
structure. Useful for lists that are bound to list views, for example
JList, JComboBox and JTable.
ArrayListModel
,
ListIterator
,
Serialized FormField Summary |
---|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
LinkedListModel()
Constructs an empty linked list. |
|
LinkedListModel(Collection<? extends E> c)
Constructs a linked list containing the elements of the specified collection, in the order they are returned by the collection's iterator. |
Method Summary | |
---|---|
boolean |
add(E e)
Appends the specified element to the end of this list. |
void |
add(int index,
E element)
Inserts the specified element at the specified position in this list. |
boolean |
addAll(int index,
Collection<? extends E> c)
Inserts all of the elements in the specified Collection into this list, starting at the specified position. |
void |
addFirst(E e)
Inserts the given element at the beginning of this list. |
void |
addLast(E e)
Appends the given element to the end of this list. |
void |
addListDataListener(ListDataListener l)
Adds a listener to the list that's notified each time a change to the data model occurs. |
void |
clear()
Removes all of the elements from this list. |
void |
fireContentsChanged(int index)
Notifies all registered ListDataListeners that the element
at the specified index has changed. |
E |
getElementAt(int index)
Returns the value at the specified index. |
ListDataListener[] |
getListDataListeners()
Returns an array of all the list data listeners registered on this LinkedListModel . |
int |
getSize()
Returns the length of the list or 0 if there's no list. |
ListIterator<E> |
listIterator(int index)
Returns a list-iterator of the elements in this list (in proper sequence), starting at the specified position in the list. |
E |
remove(int index)
Removes the element at the specified position in this list. |
boolean |
remove(Object o)
Removes a single instance of the specified element from this collection, if it is present (optional operation). |
E |
removeFirst()
Removes and returns the first element from this list. |
E |
removeLast()
Removes and returns the last element from this list. |
void |
removeListDataListener(ListDataListener l)
Removes a listener from the list that's notified each time a change to the data model occurs. |
protected void |
removeRange(int fromIndex,
int toIndex)
Removes from this List all of the elements whose index is between fromIndex, inclusive and toIndex, exclusive. |
E |
set(int index,
E element)
Replaces the element at the specified position in this list with the specified element. |
Methods inherited from class java.util.LinkedList |
---|
addAll, clone, contains, descendingIterator, element, get, getFirst, getLast, indexOf, lastIndexOf, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, removeFirstOccurrence, removeLastOccurrence, size, toArray, toArray |
Methods inherited from class java.util.AbstractSequentialList |
---|
iterator |
Methods inherited from class java.util.AbstractList |
---|
equals, hashCode, listIterator, subList |
Methods inherited from class java.util.AbstractCollection |
---|
containsAll, isEmpty, removeAll, retainAll, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
addAll, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, removeAll, retainAll, size, subList, toArray, toArray |
Methods inherited from interface java.util.Deque |
---|
iterator |
Constructor Detail |
---|
public LinkedListModel()
public LinkedListModel(Collection<? extends E> c)
c
- the collection whose elements are to be placed into this list.
NullPointerException
- if the specified collection is
null
Method Detail |
---|
public void add(int index, E element)
add
in interface List<E>
add
in class LinkedList<E>
index
- index at which the specified element is to be inserted.element
- element to be inserted.
IndexOutOfBoundsException
- if index is out of range
(index < 0 || index > size())
.public boolean add(E e)
add
in interface Collection<E>
add
in interface Deque<E>
add
in interface List<E>
add
in interface Queue<E>
add
in class LinkedList<E>
e
- element to be appended to this list.
true
(as per the general contract of Collection.add).public boolean addAll(int index, Collection<? extends E> c)
addAll
in interface List<E>
addAll
in class LinkedList<E>
index
- index at which to insert first element
from the specified collection.c
- elements to be inserted into this list.
true
if this list changed as a result of the call.
IndexOutOfBoundsException
- if index out of range
(index < 0 || index > size())
.
NullPointerException
- if the specified Collection is null.public void addFirst(E e)
addFirst
in interface Deque<E>
addFirst
in class LinkedList<E>
e
- the element to be inserted at the beginning of this list.public void addLast(E e)
add
method; included only for consistency.)
addLast
in interface Deque<E>
addLast
in class LinkedList<E>
e
- the element to be inserted at the end of this list.public void clear()
clear
in interface Collection<E>
clear
in interface List<E>
clear
in class LinkedList<E>
public E remove(int index)
remove
in interface List<E>
remove
in class LinkedList<E>
index
- the index of the element to removed.
IndexOutOfBoundsException
- if index out of range
(index < 0 || index >= size())
.public boolean remove(Object o)
e
such that (o==null ? e==null :
o.equals(e))
, if the collection contains one or more such
elements. Returns true
if the collection contained the
specified element (or equivalently, if the collection changed as a
result of the call).This implementation iterates over the collection looking for the specified element. If it finds the element, it removes the element from the collection using the iterator's remove method.
Note that this implementation throws an
UnsupportedOperationException
if the iterator returned by this
collection's iterator method does not implement the remove
method and this collection contains the specified object.
remove
in interface Collection<E>
remove
in interface Deque<E>
remove
in interface List<E>
remove
in class LinkedList<E>
o
- element to be removed from this collection, if present.
true
if the collection contained the specified
element.public E removeFirst()
removeFirst
in interface Deque<E>
removeFirst
in class LinkedList<E>
NoSuchElementException
- if this list is empty.public E removeLast()
removeLast
in interface Deque<E>
removeLast
in class LinkedList<E>
NoSuchElementException
- if this list is empty.protected void removeRange(int fromIndex, int toIndex)
(toIndex - fromIndex)
elements.
(If toIndex==fromIndex
, this operation has no effect.)
removeRange
in class AbstractList<E>
fromIndex
- index of first element to be removed.toIndex
- index after last element to be removed.public E set(int index, E element)
set
in interface List<E>
set
in class LinkedList<E>
index
- index of element to replace.element
- element to be stored at the specified position.
IndexOutOfBoundsException
- if index out of range
(index < 0 || index >= size())
.public ListIterator<E> listIterator(int index)
The list-iterator is fail-fast: if the list is structurally modified at any time after the Iterator is created, in any way except through the list-iterator's own remove or add methods, the list-iterator will throw a ConcurrentModificationException. Thus, in the face of concurrent modification, the iterator fails quickly and cleanly, rather than risking arbitrary, non-deterministic behavior at an undetermined time in the future.
listIterator
in interface List<E>
listIterator
in class LinkedList<E>
index
- index of first element to be returned from the
list-iterator (by a call to next).
IndexOutOfBoundsException
- if index is out of range
(index < 0 || index > size()).List.listIterator(int)
public void addListDataListener(ListDataListener l)
addListDataListener
in interface ListModel
l
- the ListDataListener
to be addedpublic void removeListDataListener(ListDataListener l)
removeListDataListener
in interface ListModel
l
- the ListDataListener
to be removedpublic E getElementAt(int index)
getElementAt
in interface ListModel
index
- the requested index
index
public int getSize()
getSize
in interface ListModel
public void fireContentsChanged(int index)
ListDataListeners
that the element
at the specified index has changed. Useful if there's a content change
without any structural change.This method must be called after the element of the list changes.
index
- the index of the element that has changedEventListenerList
public ListDataListener[] getListDataListeners()
LinkedListModel
.
ListDataListener
s,
or an empty array if no list data listeners
are currently registeredaddListDataListener(ListDataListener)
,
removeListDataListener(ListDataListener)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |