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
ConstructorDescriptioninitializes 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 TypeMethodDescriptionvoid
Inserts the specified element at the specified position in this list.void
addElement
(Object obj) Adds the specified component to the end of this list.boolean
Tests whether 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 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.boolean
getChecked
(int index) returns the checked state of the element at the given indexgetElementAt
(int index) Returns the component at the specified index.int
Searches for the first occurrence of elem.int
Searches for the first occurrence of elem, beginning the search at index.void
insertElementAt
(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.int
lastIndexOf
(Object elem) Returns the index of the last occurrence of elem.int
lastIndexOf
(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.boolean
removeElement
(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.void
setChecked
(int index, boolean checked) sets the checked state of the element at the given indexvoid
setElementAt
(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, trimToSize
Methods 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:
add
in 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:
addElement
in classDefaultListModel
- Parameters:
obj
- the component to be added
-
contains
Tests whether the specified object is a component in this list.- Overrides:
contains
in 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:
copyInto
in 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:
elementAt
in 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:
firstElement
in classDefaultListModel
- Returns:
- the first component of this list
- Throws:
NoSuchElementException
-
get
Returns the element at the specified position in this list.- Overrides:
get
in classDefaultListModel
- Parameters:
index
- of element to return- Throws:
ArrayIndexOutOfBoundsException
-
getElementAt
Returns the component at the specified index.- Specified by:
getElementAt
in interfaceListModel
- Overrides:
getElementAt
in 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:
indexOf
in 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:
indexOf
in 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:
insertElementAt
in 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:
lastElement
in classDefaultListModel
- Returns:
- the last component of the list
- Throws:
NoSuchElementException
-
lastIndexOf
Returns the index of the last occurrence of elem.- Overrides:
lastIndexOf
in 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:
lastIndexOf
in 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:
remove
in 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:
removeElement
in 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:
set
in 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:
setElementAt
in 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:
toArray
in 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
-