|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.AbstractListModel com.alee.laf.list.WebListModel<T>
public class WebListModel<T>
Modified and optimized Swing DefaultListModel. This model contains multiply elements add/remove methods and works with typed elements.
Field Summary | |
---|---|
protected java.util.Vector<T> |
delegate
List data vector. |
Fields inherited from class javax.swing.AbstractListModel |
---|
listenerList |
Constructor Summary | |
---|---|
WebListModel()
Constructs empty model. |
|
WebListModel(java.util.Collection<T> data)
Constructs model with the specified elements. |
|
WebListModel(T... data)
Constructs model with the specified elements. |
Method Summary | |
---|---|
void |
add(int index,
T element)
Inserts the specified element at the specified position in this list. |
void |
add(T element)
Adds the specified element to this list. |
void |
addElement(T obj)
Adds the specified component to the end of this list. |
void |
addElements(java.util.Collection<T> objects)
Adds the specified components to the end of this list. |
void |
addElements(T... objects)
Adds the specified components to the end of this list. |
int |
capacity()
Returns the current capacity of this list. |
void |
clear()
Removes all of the elements from this list. |
boolean |
contains(T elem)
Tests whether the specified object is a component in this list. |
void |
copyInto(T[] array)
Copies the components of this list into the specified array. |
T |
elementAt(int index)
Returns the component at the specified index. |
java.util.Enumeration<T> |
elements()
Returns an enumeration of the components of this list. |
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. |
T |
firstElement()
Returns the first component of this list. |
T |
get(int index)
Returns the element at the specified position in this list. |
T |
getElementAt(int index)
Returns the component at the specified index. |
java.util.List<T> |
getElements()
Returns list of all elements. |
int |
getSize()
Returns the number of components in this list. |
int |
indexOf(T elem)
Searches for the first occurrence of elem . |
int |
indexOf(T elem,
int index)
Searches for the first occurrence of elem , beginning the search at index . |
void |
insertElementAt(T obj,
int index)
Inserts the specified object as a component in this list at the specified index . |
boolean |
isEmpty()
Tests whether this list has any components. |
T |
lastElement()
Returns the last component of the list. |
int |
lastIndexOf(T elem)
Returns the index of the last occurrence of elem . |
int |
lastIndexOf(T elem,
int index)
Searches backwards for elem , starting from the specified index, and returns an index to it. |
T |
remove(int index)
Removes the element at the specified position in this list. |
T |
remove(T element)
Removes the specified element from this list. |
void |
removeAllAfter(int index)
Removes all elements from this list which has index larger than the specified one. |
void |
removeAllBefore(int index)
Removes all elements from this list which has index lower than the specified one. |
void |
removeAllElements()
Removes all components from this list and sets its size to zero. |
boolean |
removeElement(T object)
Removes the first (lowest-indexed) occurrence of the argument from this list. |
void |
removeElementAt(int index)
Deletes the component at the specified index. |
void |
removeElements(java.util.Collection<T> objects)
Removes the specified elements from this list. |
void |
removeElements(T... objects)
Removes the specified elements from this list. |
void |
removeRange(int fromIndex,
int toIndex)
Deletes the components at the specified range of indexes. |
T |
set(int index,
T element)
Replaces the element at the specified position in this list with the specified element. |
void |
setElementAt(T obj,
int index)
Sets the component at the specified index of this list to be the specified object. |
void |
setElements(java.util.Collection<T> objects)
Clears list data and adds specified elements. |
void |
setSize(int newSize)
Sets the size of this list. |
int |
size()
Returns the number of components in this list. |
java.lang.Object[] |
toArray()
Returns an array containing all of the elements in this list in the correct order. |
java.lang.String |
toString()
Returns a string that displays and identifies this object's properties. |
void |
trimToSize()
Trims the capacity of this list to be the list's current size. |
void |
update(T element)
Updates cell for the specified element. |
Methods inherited from class javax.swing.AbstractListModel |
---|
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.util.Vector<T> delegate
Constructor Detail |
---|
public WebListModel()
public WebListModel(T... data)
public WebListModel(java.util.Collection<T> data)
Method Detail |
---|
public int getSize()
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.
size()
public T getElementAt(int index)
Note: Although this method is not deprecated, the preferred method to use isget(int)
, which implements theList
interface defined in the 1.2 Collections framework.
index
- an index into this list
java.lang.ArrayIndexOutOfBoundsException
- if the index
is negative or greater than the current size of this listget(int)
public java.util.List<T> getElements()
public void copyInto(T[] array)
IndexOutOfBoundsException
is thrown.
array
- the array into which the components get copiedpublic void trimToSize()
Vector.trimToSize()
public void ensureCapacity(int minCapacity)
minCapacity
- the desired minimum capacityVector.ensureCapacity(int)
public void setSize(int newSize)
newSize
- the new size of this listVector.setSize(int)
public int capacity()
Vector.capacity()
public int size()
Vector.size()
public boolean isEmpty()
true
if and only if this list has no components, that is, its size is zero; false
otherwiseVector.isEmpty()
public java.util.Enumeration<T> elements()
Vector.elements()
public boolean contains(T elem)
elem
- an object
true
if the specified object is the same as a component in this listVector.contains(Object)
public int indexOf(T elem)
elem
.
elem
- an object
-1
if the object is not foundVector.indexOf(Object)
public int indexOf(T elem, int index)
elem
, beginning the search at index
.
elem
- an desired componentindex
- the index from which to begin searching
elem
is found after index
; returns -1
if the
elem
is not found in the listVector.indexOf(Object, int)
public int lastIndexOf(T elem)
elem
.
elem
- the desired component
elem
in the list; returns -1
if the object is not foundVector.lastIndexOf(Object)
public int lastIndexOf(T elem, int index)
elem
, starting from the specified index, and returns an index to it.
elem
- the desired componentindex
- the index to start searching from
elem
in this list at position less than index
; returns
-1
if the object is not foundVector.lastIndexOf(Object, int)
public T elementAt(int index)
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 isget(int)
, which implements theList
interface defined in the 1.2 Collections framework.
index
- an index into this list
get(int)
,
Vector.elementAt(int)
public T firstElement()
NoSuchElementException
if this vector has no components.
Vector.firstElement()
public T lastElement()
NoSuchElementException
if this vector has no components.
Vector.lastElement()
public void setElementAt(T obj, int index)
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 isset(int, Object)
, which implements theList
interface defined in the 1.2 Collections framework.
obj
- what the component is to be set toindex
- the specified indexset(int, Object)
,
Vector.setElementAt(Object, int)
public void removeElementAt(int index)
ArrayIndexOutOfBoundsException
if the index is invalid. Note: Although this method is not deprecated, the preferred method to use isremove(int)
, which implements theList
interface defined in the 1.2 Collections framework.
index
- the index of the object to removeremove(int)
,
Vector.removeElementAt(int)
public void insertElementAt(T obj, int index)
index
.
Throws an ArrayIndexOutOfBoundsException
if the index is invalid. Note: Although this method is not deprecated, the preferred method to use isadd(int, Object)
, which implements theList
interface defined in the 1.2 Collections framework.
obj
- the component to insertindex
- where to insert the new component
java.lang.ArrayIndexOutOfBoundsException
- if the index was invalidadd(int, Object)
,
Vector.insertElementAt(Object, int)
public void addElement(T obj)
obj
- the component to be addedVector.addElement(Object)
public void addElements(T... objects)
objects
- the components to be addedpublic void addElements(java.util.Collection<T> objects)
objects
- the components to be addedpublic void setElements(java.util.Collection<T> objects)
objects
- the components to be addedpublic boolean removeElement(T object)
object
- the component to be removed
true
if the argument was a component of this list; false
otherwiseVector.removeElement(Object)
public void removeElements(T... objects)
objects
- the components to be removedpublic void removeElements(java.util.Collection<T> objects)
objects
- the components to be removedpublic void removeAllElements()
Note: Although this method is not deprecated, the preferred method to use isclear
, which implements theList
interface defined in the 1.2 Collections framework.
clear()
,
Vector.removeAllElements()
public void removeAllBefore(int index)
index
- index to processpublic void removeAllAfter(int index)
index
- index to processpublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.Object[] toArray()
Vector.toArray()
public T get(int index)
ArrayIndexOutOfBoundsException
if the index is out of range (index < 0 || index >=
size()
).
index
- index of element to returnpublic T set(int index, T element)
ArrayIndexOutOfBoundsException
if the index is out of range (index < 0 || index >=
size()
).
index
- index of element to replaceelement
- element to be stored at the specified position
public void add(T element)
element
- element to be addedpublic void add(int index, T element)
ArrayIndexOutOfBoundsException
if the index is out of range (index < 0 || index > size()
).
index
- index at which the specified element is to be insertedelement
- element to be insertedpublic T remove(T element)
element
- element to remove
public T remove(int index)
ArrayIndexOutOfBoundsException
if the index is out of range (index < 0 || index >=
size()
).
index
- the index of the element to removed
public void clear()
public void removeRange(int fromIndex, int toIndex)
ArrayIndexOutOfBoundsException
if the index was invalid. Throws an IllegalArgumentException
if
fromIndex > toIndex
.
fromIndex
- the index of the lower end of the rangetoIndex
- the index of the upper end of the rangeremove(int)
public void update(T element)
element
- element to update
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |