Package weka.gui
Class CheckBoxList.CheckBoxListModel
java.lang.Object
javax.swing.AbstractListModel<E>
javax.swing.DefaultListModel
weka.gui.CheckBoxList.CheckBoxListModel
- All Implemented Interfaces:
Serializable,ListModel
- Enclosing class:
- CheckBoxList
A specialized model.
- Version:
- $Revision: 10219 $
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptioninitializes the model with no data.CheckBoxListModel(Object[] listData) Constructs a CheckBoxListModel from an array of objects and then applies setModel to it.CheckBoxListModel(Vector listData) Constructs a CheckBoxListModel from a Vector and then applies setModel to it. -
Method Summary
Modifier and TypeMethodDescriptionvoidInserts the specified element at the specified position in this list.voidaddElement(Object obj) Adds the specified component to the end of this list.booleanTests whether the specified object is a component in this list.voidCopies the components of this list into the specified array.elementAt(int index) Returns the component at the specified index.Returns the first component of this list.get(int index) Returns the element at the specified position in this list.booleangetChecked(int index) returns the checked state of the element at the given indexgetElementAt(int index) Returns the component at the specified index.intSearches for the first occurrence of elem.intSearches for the first occurrence of elem, beginning the search at index.voidinsertElementAt(Object obj, int index) Inserts the specified object as a component in this list at the specified index.Returns the last component of the list.intlastIndexOf(Object elem) Returns the index of the last occurrence of elem.intlastIndexOf(Object elem, int index) Searches backwards for elem, starting from the specified index, and returns an index to it.remove(int index) Removes the element at the specified position in this list.booleanremoveElement(Object obj) Removes the first (lowest-indexed) occurrence of the argument from this list.Replaces the element at the specified position in this list with the specified element.voidsetChecked(int index, boolean checked) sets the checked state of the element at the given indexvoidsetElementAt(Object obj, int index) Sets the component at the specified index of this list to be the specified object.Object[]toArray()Returns an array containing all of the elements in this list in the correct order.Methods inherited from class javax.swing.DefaultListModel
addAll, addAll, capacity, clear, elements, ensureCapacity, getSize, isEmpty, removeAllElements, removeElementAt, removeRange, setSize, size, toString, trimToSizeMethods inherited from class javax.swing.AbstractListModel
addListDataListener, getListDataListeners, getListeners, removeListDataListener
-
Constructor Details
-
CheckBoxListModel
public CheckBoxListModel()initializes the model with no data. -
CheckBoxListModel
Constructs a CheckBoxListModel from an array of objects and then applies setModel to it.- Parameters:
listData- the data to use
-
CheckBoxListModel
Constructs a CheckBoxListModel from a Vector and then applies setModel to it.
-
-
Method Details
-
add
Inserts the specified element at the specified position in this list.- Overrides:
addin classDefaultListModel- Parameters:
index- index at which the specified element is to be insertedelement- element to be inserted
-
addElement
Adds the specified component to the end of this list.- Overrides:
addElementin classDefaultListModel- Parameters:
obj- the component to be added
-
contains
Tests whether the specified object is a component in this list.- Overrides:
containsin classDefaultListModel- Parameters:
elem- the element to check- Returns:
- true if the element is in the list
-
copyInto
Copies the components of this list into the specified array.- Overrides:
copyIntoin classDefaultListModel- Parameters:
anArray- the array into which the components get copied- Throws:
IndexOutOfBoundsException- if the array is not big enough
-
elementAt
Returns the component at the specified index. Throws an ArrayIndexOutOfBoundsException if the index is negative or not less than the size of the list.- Overrides:
elementAtin classDefaultListModel- Parameters:
index- an index into this list- Returns:
- the component at the specified index
- Throws:
ArrayIndexOutOfBoundsException
-
firstElement
Returns the first component of this list. Throws a NoSuchElementException if this vector has no components.- Overrides:
firstElementin classDefaultListModel- Returns:
- the first component of this list
- Throws:
NoSuchElementException
-
get
Returns the element at the specified position in this list.- Overrides:
getin classDefaultListModel- Parameters:
index- of element to return- Throws:
ArrayIndexOutOfBoundsException
-
getElementAt
Returns the component at the specified index.- Specified by:
getElementAtin interfaceListModel- Overrides:
getElementAtin classDefaultListModel- Parameters:
index- an index into this list- Returns:
- the component at the specified index
- Throws:
ArrayIndexOutOfBoundsException
-
indexOf
Searches for the first occurrence of elem.- Overrides:
indexOfin classDefaultListModel- 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
-
indexOf
Searches for the first occurrence of elem, beginning the search at index.- Overrides:
indexOfin classDefaultListModel- Parameters:
elem- the desired componentindex- the index from which to begin searching- Returns:
- the index where the first occurrence of elem is found after index; returns -1 if the elem is not found in the list
-
insertElementAt
Inserts the specified object as a component in this list at the specified index.- Overrides:
insertElementAtin classDefaultListModel- Parameters:
obj- the component to insertindex- where to insert the new component- Throws:
ArrayIndexOutOfBoundsException
-
lastElement
Returns the last component of the list. Throws a NoSuchElementException if this vector has no components.- Overrides:
lastElementin classDefaultListModel- Returns:
- the last component of the list
- Throws:
NoSuchElementException
-
lastIndexOf
Returns the index of the last occurrence of elem.- Overrides:
lastIndexOfin classDefaultListModel- Parameters:
elem- the desired component- Returns:
- the index of the last occurrence of elem in the list; returns -1 if the object is not found
-
lastIndexOf
Searches backwards for elem, starting from the specified index, and returns an index to it.- Overrides:
lastIndexOfin classDefaultListModel- Parameters:
elem- the desired componentindex- the index to start searching from- Returns:
- the index of the last occurrence of the elem in this list at position less than index; returns -1 if the object is not found
-
remove
Removes the element at the specified position in this list. Returns the element that was removed from the list.- Overrides:
removein classDefaultListModel- Parameters:
index- the index of the element to removed- Throws:
ArrayIndexOutOfBoundsException
-
removeElement
Removes the first (lowest-indexed) occurrence of the argument from this list.- Overrides:
removeElementin classDefaultListModel- Parameters:
obj- the component to be removed- Returns:
- true if the argument was a component of this list; false otherwise
-
set
Replaces the element at the specified position in this list with the specified element.- Overrides:
setin classDefaultListModel- Parameters:
index- index of element to replaceelement- element to be stored at the specified position- Throws:
ArrayIndexOutOfBoundsException
-
setElementAt
Sets the component at the specified index of this list to be the specified object. The previous component at that position is discarded.- Overrides:
setElementAtin classDefaultListModel- Parameters:
obj- what the component is to be set toindex- the specified index- Throws:
ArrayIndexOutOfBoundsException
-
toArray
Returns an array containing all of the elements in this list in the correct order.- Overrides:
toArrayin classDefaultListModel- Returns:
- an array containing the elements of the list
-
getChecked
public boolean getChecked(int index) returns the checked state of the element at the given index- Parameters:
index- the index of the element to return the checked state for- Returns:
- the checked state of the specifed element
-
setChecked
public void setChecked(int index, boolean checked) sets the checked state of the element at the given index- Parameters:
index- the index of the element to set the checked state forchecked- the new checked state
-