Class RmaListModel<E>
- All Implemented Interfaces:
Serializable
,ComboBoxModel<E>
,ListModel<E>
,MutableComboBoxModel<E>
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected boolean
protected boolean
protected Object
Fields 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 TypeMethodDescriptionvoid
Inserts the specified element at the specified position in this list.void
void
addAll
(Collection<? extends E> c) void
addElement
(E obj) Adds the specified component to the list.void
addElements
(E[] objs) Adds the specified components to the list.int
capacity()
Deprecated.boolean
checkComparable
(List list) void
clear()
Removes all of the elements from this list.protected int
the method called during inserting an item in the list that is sortedboolean
Tests if the specified object is a component in this list.void
Copies the components of this list into the specified array.elementAt
(int index) Returns the element at the specified position in this list.elements()
Deprecated.void
ensureCapacity
(int minCapacity) Deprecated.void
fireContentsChanged
(int startRowIndex, int endRowIndex) Deprecated.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.get
(int index) Returns the component at the specified index.boolean
getElementAt
(int index) Returns the component at the specified index.int
getIndexOf
(Object anObject) Returns the index-position of the specified object in the list.getList()
int
int
getSize()
Returns the number of components in this list.int
Searches for the first occurence of the given argument.int
Deprecated.void
insertElementAt
(E obj, int index) Inserts the specified object as a component in this list at the specifiedindex
.boolean
boolean
isEmpty()
Tests if this list has no components.boolean
Returns true if the list model is sorting its elements.iterator()
Deprecated.int
lastIndexOf
(Object elem) Returns the index of the last occurrence of the specified object in this list.int
lastIndexOf
(Object elem, int index) Deprecated.int
lastIndexOf
(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 void
remove
(int index) Removes the element at the specified position in this list.void
Removes all components from this list and sets its size to zero.void
removeElement
(Object obj) 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
(Object[] objs) Removes the first (lowest-indexed) occurrence of the arguments from this list.void
removeRange
(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.void
Replaces the current contents with the contents of the Object Arrayvoid
setAll
(Collection<? extends E> c) void
setAscendingSort
(boolean tf) void
setCaseInsensitiveSort
(boolean caseInsensitiveSort) void
setElementAt
(E obj, int index) Sets the component at the specifiedindex
of this list to be the specified object.void
setEnableSort
(boolean enableSort) void
setSelectedItem
(Object anObject) void
setSize
(int newSize) Deprecated.int
size()
Returns the number of components in this list.boolean
sort()
Object[]
toArray()
Returns an array containing all of the elements in this list in the correct order.toString()
void
Deprecated.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
Methods 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:
getElementAt
in 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:
true
if and only if this list has no components, that is, its size is zero;false
otherwise.- 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:
true
if 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
-1
if 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
-1
if 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
-1
if 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
index
or later in the list; returns-1
if 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
-1
if 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
index
in the list;-1
if 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 specifiedindex
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:
-
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:
removeElementAt
in 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:
insertElementAt
in 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:
addElement
in 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:
removeElement
in 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:
setSelectedItem
in interfaceComboBoxModel<E>
-
getSelectedItem
- Specified by:
getSelectedItem
in 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)
-