Class RmaListModel<E>
- All Implemented Interfaces:
Serializable,ComboBoxModel<E>,ListModel<E>,MutableComboBoxModel<E>
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected booleanprotected booleanprotected ObjectFields inherited from class javax.swing.AbstractListModel
listenerList -
Constructor Summary
ConstructorsConstructorDescriptionRmaListModel(boolean enableSort) RmaListModel(boolean enableSort, E... items) RmaListModel(boolean enableSort, Collection<E> items) -
Method Summary
Modifier and TypeMethodDescriptionvoidInserts the specified element at the specified position in this list.voidvoidaddAll(Collection<? extends E> c) voidaddElement(E obj) Adds the specified component to the list.voidaddElements(E[] objs) Adds the specified components to the list.intcapacity()Deprecated.booleancheckComparable(List list) voidclear()Removes all of the elements from this list.protected intthe method called during inserting an item in the list that is sortedbooleanTests if the specified object is a component in this list.voidCopies the components of this list into the specified array.elementAt(int index) Returns the element at the specified position in this list.elements()Deprecated.voidensureCapacity(int minCapacity) Deprecated.voidfireContentsChanged(int startRowIndex, int endRowIndex) Deprecated.intfirstIndexOf(String match, int index, boolean wrap, boolean wholeWord, boolean caseSensitive) Returns the index of an object in this list using a string match.get(int index) Returns the component at the specified index.booleangetElementAt(int index) Returns the component at the specified index.intgetIndexOf(Object anObject) Returns the index-position of the specified object in the list.getList()intintgetSize()Returns the number of components in this list.intSearches for the first occurence of the given argument.intDeprecated.voidinsertElementAt(E obj, int index) Inserts the specified object as a component in this list at the specifiedindex.booleanbooleanisEmpty()Tests if this list has no components.booleanReturns true if the list model is sorting its elements.iterator()Deprecated.intlastIndexOf(Object elem) Returns the index of the last occurrence of the specified object in this list.intlastIndexOf(Object elem, int index) Deprecated.intlastIndexOf(String match, int index, boolean wholeWord, boolean caseSensitive) Iterating from rear to front, returns the first occurance of an object in this list using a string match.static voidremove(int index) Removes the element at the specified position in this list.voidRemoves all components from this list and sets its size to zero.voidremoveElement(Object obj) Removes the first (lowest-indexed) occurrence of the argument from this list.voidremoveElementAt(int index) Deletes the component at the specified index.voidremoveElements(Object[] objs) Removes the first (lowest-indexed) occurrence of the arguments from this list.voidremoveRange(int fromIndex, int toIndex) Deletes the components at the specified range of indexes.Replaces the element at the specified position in this list with the specified element.voidReplaces the current contents with the contents of the Object ArrayvoidsetAll(Collection<? extends E> c) voidsetAscendingSort(boolean tf) voidsetCaseInsensitiveSort(boolean caseInsensitiveSort) voidsetElementAt(E obj, int index) Sets the component at the specifiedindexof this list to be the specified object.voidsetEnableSort(boolean enableSort) voidsetSelectedItem(Object anObject) voidsetSize(int newSize) Deprecated.intsize()Returns the number of components in this list.booleansort()Object[]toArray()Returns an array containing all of the elements in this list in the correct order.toString()voidDeprecated.Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface javax.swing.ListModel
addListDataListener, removeListDataListener
-
Field Details
-
_ascendingSort
protected boolean _ascendingSort -
_enableSort
protected boolean _enableSort -
_caseInsensitiveSort
protected boolean _caseInsensitiveSort -
_selectedObject
-
delegate
-
-
Constructor Details
-
RmaListModel
public RmaListModel() -
RmaListModel
public RmaListModel(boolean enableSort) -
RmaListModel
-
RmaListModel
-
-
Method Details
-
setAscendingSort
public void setAscendingSort(boolean tf) -
isAscendingSort
public boolean isAscendingSort() -
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.
-
getElementAt
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.
- Specified by:
getElementAtin interfaceListModel<E>- Parameters:
index- an index into this list.- Returns:
- the component at the specified index.
- Throws:
ArrayIndexOutOfBoundsException- if the index is negative or not less than the current size of this list. given.- See Also:
-
copyInto
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:
-
trimToSize
Deprecated.Trims the capacity of this list to be the list's current size. No-op unless the delegate is a Vector.- See Also:
-
ensureCapacity
Deprecated.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. No-op unless the delegate is a Vector.- Parameters:
minCapacity- the desired minimum capacity.- See Also:
-
setSize
Deprecated.Sets the size of this list. No-op unless the delegate is a Vector.- Parameters:
newSize- the new size of this list.- See Also:
-
capacity
Deprecated.For a vector, Returns the current capacity of this vector For any other list type, returns the size- Returns:
- the current capacity
- See Also:
-
size
public int size()Returns the number of components in this list.- Returns:
- the number of components in this list.
- See Also:
-
isEmpty
public boolean isEmpty()Tests if this list has no components.- Returns:
trueif and only if this list has no components, that is, its size is zero;falseotherwise.- See Also:
-
elements
Deprecated.Returns an enumeration of the components of this list.- Returns:
- an enumeration of the components of this list.
- See Also:
-
iterator
-
contains
Tests if the specified object is a component in this list.- Parameters:
elem- an object.- Returns:
trueif the specified object is the same as a component in this list- See Also:
-
firstIndexOf
public int firstIndexOf(String match, int index, boolean wrap, boolean wholeWord, boolean caseSensitive) Returns the index of an object in this list using a string match.- Parameters:
match- The string to match.index- The index to start the search at.wrap- When the end of the model is reached do we wrap to the front?wholeWord- Whether to match only whole words or not.caseSensitive- Is the match case sensitive?- Returns:
- the index of the first object that matches the search
criteria; returns
-1if no object matches the search criteria.
-
lastIndexOf
Iterating from rear to front, returns the first occurance of an object in this list using a string match.- Parameters:
match- The string to match.index- The index to start the search at.wholeWord- Whether to match only whole words or not.caseSensitive- Is the match case sensitive?- Returns:
- the index of the last object that matches the search
criteria; returns
-1if no object matches the search criteria.
-
indexOf
Searches for the first occurence of the given argument.- Parameters:
elem- an object.- Returns:
- the index of the first occurrence of the argument in this
list; returns
-1if the object is not found. - See Also:
-
indexOf
Deprecated.Searches for the first occurence of the given argument, beginning the search atindex. No-op and returns -1 if delegate is not a vector- Parameters:
elem- an object.index- the index to start searching from.- Returns:
- the index of the first occurrence of the object argument in
this list at position
indexor later in the list; returns-1if the object is not found. - See Also:
-
lastIndexOf
Returns the index of the last occurrence of the specified object in this list.- Parameters:
elem- the desired component.- Returns:
- the index of the last occurrence of the specified object in
this list; returns
-1if the object is not found. - See Also:
-
lastIndexOf
Deprecated.Searches backwards for the specified object, starting from the specified index, and returns an index to it. No-op and returns -1 if delegate is not a vector- Parameters:
elem- the desired component.index- the index to start searching from.- Returns:
- the index of the last occurrence of the specified object in this
list at position less than
indexin the list;-1if the object is not found. - See Also:
-
get
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:
-
getIndexOf
Returns the index-position of the specified object in the list.- Parameters:
anObject-- Returns:
- an int representing the index position, where 0 is the first position
-
firstElement
Deprecated.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:
-
lastElement
Deprecated.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:
-
setElementAt
Sets the component at the specifiedindexof 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:
-
removeElementAt
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.
- Specified by:
removeElementAtin interfaceMutableComboBoxModel<E>- Parameters:
index- the index of the object to remove.- See Also:
-
insertElementAt
Inserts the specified object as a component in this list at the specifiedindex.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.
- Specified by:
insertElementAtin interfaceMutableComboBoxModel<E>- Parameters:
obj- the component to insert.index- where to insert the new component.- Throws:
ArrayIndexOutOfBoundsException- if the index was invalid.- See Also:
-
checkComparable
-
getCaseInsensitiveSort
public boolean getCaseInsensitiveSort() -
setCaseInsensitiveSort
public void setCaseInsensitiveSort(boolean caseInsensitiveSort) -
sort
public boolean sort() -
addElements
Adds the specified components to the list.- Parameters:
objs- the components to be added.
-
addElement
Adds the specified component to the list.- Specified by:
addElementin interfaceMutableComboBoxModel<E>- Parameters:
obj- the component to be added.- See Also:
-
compare
the method called during inserting an item in the list that is sorted- See Also:
-
removeElement
Removes the first (lowest-indexed) occurrence of the argument from this list.- Specified by:
removeElementin interfaceMutableComboBoxModel<E>- Parameters:
obj- the component to be removed.- See Also:
-
removeElements
Removes the first (lowest-indexed) occurrence of the arguments from this list.- Parameters:
objs- the components to be removed.
-
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:
-
toArray
Returns an array containing all of the elements in this list in the correct order.Throws an ArrayStoreException if the runtime type of the array a is not a supertype of the runtime type of every element in this list.
- Returns:
- an array containing the elements of the list.
- See Also:
-
elementAt
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
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
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
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
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
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 rangetoIndex- the index of the upper end of the range- See Also:
-
setEnableSort
public void setEnableSort(boolean enableSort) -
isEnableSort
public boolean isEnableSort()Returns true if the list model is sorting its elements. -
setSelectedItem
- Specified by:
setSelectedItemin interfaceComboBoxModel<E>
-
getSelectedItem
- Specified by:
getSelectedItemin interfaceComboBoxModel<E>
-
getSelectedIndex
public int getSelectedIndex() -
setAll
Replaces the current contents with the contents of the Object Array -
setAll
-
addAll
-
addAll
-
getVector
-
getList
-
toString
-
main
-
fireContentsChanged
public void fireContentsChanged(int startRowIndex, int endRowIndex)
-