Package weka.gui
Class CheckBoxList.CheckBoxListModel
- java.lang.Object
-
- javax.swing.AbstractListModel<E>
-
- javax.swing.DefaultListModel
-
- weka.gui.CheckBoxList.CheckBoxListModel
-
- All Implemented Interfaces:
java.io.Serializable,javax.swing.ListModel
- Enclosing class:
- CheckBoxList
public class CheckBoxList.CheckBoxListModel extends javax.swing.DefaultListModelA specialized model.- Version:
- $Revision: 7059 $
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CheckBoxListModel()initializes the model with no data.CheckBoxListModel(java.lang.Object[] listData)Constructs a CheckBoxListModel from an array of objects and then applies setModel to it.CheckBoxListModel(java.util.Vector listData)Constructs a CheckBoxListModel from a Vector and then applies setModel to it.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, java.lang.Object element)Inserts the specified element at the specified position in this list.voidaddElement(java.lang.Object obj)Adds the specified component to the end of this list.booleancontains(java.lang.Object elem)Tests whether the specified object is a component in this list.voidcopyInto(java.lang.Object[] anArray)Copies the components of this list into the specified array.java.lang.ObjectelementAt(int index)Returns the component at the specified index.java.lang.ObjectfirstElement()Returns the first component of this list.java.lang.Objectget(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 indexjava.lang.ObjectgetElementAt(int index)Returns the component at the specified index.intindexOf(java.lang.Object elem)Searches for the first occurrence of elem.intindexOf(java.lang.Object elem, int index)Searches for the first occurrence of elem, beginning the search at index.voidinsertElementAt(java.lang.Object obj, int index)Inserts the specified object as a component in this list at the specified index.java.lang.ObjectlastElement()Returns the last component of the list.intlastIndexOf(java.lang.Object elem)Returns the index of the last occurrence of elem.intlastIndexOf(java.lang.Object elem, int index)Searches backwards for elem, starting from the specified index, and returns an index to it.java.lang.Objectremove(int index)Removes the element at the specified position in this list.booleanremoveElement(java.lang.Object obj)Removes the first (lowest-indexed) occurrence of the argument from this list.java.lang.Objectset(int index, java.lang.Object element)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(java.lang.Object obj, int index)Sets the component at the specified index of this list to be the specified object.java.lang.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
-
-
-
-
Constructor Detail
-
CheckBoxListModel
public CheckBoxListModel()
initializes the model with no data.
-
CheckBoxListModel
public CheckBoxListModel(java.lang.Object[] listData)
Constructs a CheckBoxListModel from an array of objects and then applies setModel to it.- Parameters:
listData- the data to use
-
CheckBoxListModel
public CheckBoxListModel(java.util.Vector listData)
Constructs a CheckBoxListModel from a Vector and then applies setModel to it.
-
-
Method Detail
-
add
public void add(int index, java.lang.Object element)Inserts the specified element at the specified position in this list.- Overrides:
addin classjavax.swing.DefaultListModel- Parameters:
index- index at which the specified element is to be insertedelement- element to be inserted
-
addElement
public void addElement(java.lang.Object obj)
Adds the specified component to the end of this list.- Overrides:
addElementin classjavax.swing.DefaultListModel- Parameters:
obj- the component to be added
-
contains
public boolean contains(java.lang.Object elem)
Tests whether the specified object is a component in this list.- Overrides:
containsin classjavax.swing.DefaultListModel- Parameters:
elem- the element to check- Returns:
- true if the element is in the list
-
copyInto
public void copyInto(java.lang.Object[] anArray)
Copies the components of this list into the specified array.- Overrides:
copyIntoin classjavax.swing.DefaultListModel- Parameters:
anArray- the array into which the components get copied- Throws:
java.lang.IndexOutOfBoundsException- if the array is not big enough
-
elementAt
public java.lang.Object elementAt(int index)
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 classjavax.swing.DefaultListModel- Parameters:
index- an index into this list- Returns:
- the component at the specified index
- Throws:
java.lang.ArrayIndexOutOfBoundsException
-
firstElement
public java.lang.Object firstElement()
Returns the first component of this list. Throws a NoSuchElementException if this vector has no components.- Overrides:
firstElementin classjavax.swing.DefaultListModel- Returns:
- the first component of this list
- Throws:
NoSuchElementException
-
get
public java.lang.Object get(int index)
Returns the element at the specified position in this list.- Overrides:
getin classjavax.swing.DefaultListModel- Parameters:
index- of element to return- Throws:
java.lang.ArrayIndexOutOfBoundsException
-
getElementAt
public java.lang.Object getElementAt(int index)
Returns the component at the specified index.- Specified by:
getElementAtin interfacejavax.swing.ListModel- Overrides:
getElementAtin classjavax.swing.DefaultListModel- Parameters:
index- an index into this list- Returns:
- the component at the specified index
- Throws:
java.lang.ArrayIndexOutOfBoundsException
-
indexOf
public int indexOf(java.lang.Object elem)
Searches for the first occurrence of elem.- Overrides:
indexOfin classjavax.swing.DefaultListModel- 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
public int indexOf(java.lang.Object elem, int index)Searches for the first occurrence of elem, beginning the search at index.- Overrides:
indexOfin classjavax.swing.DefaultListModel- 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
public void insertElementAt(java.lang.Object obj, int index)Inserts the specified object as a component in this list at the specified index.- Overrides:
insertElementAtin classjavax.swing.DefaultListModel- Parameters:
obj- the component to insertindex- where to insert the new component- Throws:
java.lang.ArrayIndexOutOfBoundsException
-
lastElement
public java.lang.Object lastElement()
Returns the last component of the list. Throws a NoSuchElementException if this vector has no components.- Overrides:
lastElementin classjavax.swing.DefaultListModel- Returns:
- the last component of the list
- Throws:
NoSuchElementException
-
lastIndexOf
public int lastIndexOf(java.lang.Object elem)
Returns the index of the last occurrence of elem.- Overrides:
lastIndexOfin classjavax.swing.DefaultListModel- 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
public int lastIndexOf(java.lang.Object elem, int index)Searches backwards for elem, starting from the specified index, and returns an index to it.- Overrides:
lastIndexOfin classjavax.swing.DefaultListModel- 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
public java.lang.Object remove(int index)
Removes the element at the specified position in this list. Returns the element that was removed from the list.- Overrides:
removein classjavax.swing.DefaultListModel- Parameters:
index- the index of the element to removed- Throws:
java.lang.ArrayIndexOutOfBoundsException
-
removeElement
public boolean removeElement(java.lang.Object obj)
Removes the first (lowest-indexed) occurrence of the argument from this list.- Overrides:
removeElementin classjavax.swing.DefaultListModel- Parameters:
obj- the component to be removed- Returns:
- true if the argument was a component of this list; false otherwise
-
set
public java.lang.Object set(int index, java.lang.Object element)Replaces the element at the specified position in this list with the specified element.- Overrides:
setin classjavax.swing.DefaultListModel- Parameters:
index- index of element to replaceelement- element to be stored at the specified position- Throws:
java.lang.ArrayIndexOutOfBoundsException
-
setElementAt
public void setElementAt(java.lang.Object obj, int index)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 classjavax.swing.DefaultListModel- Parameters:
obj- what the component is to be set toindex- the specified index- Throws:
java.lang.ArrayIndexOutOfBoundsException
-
toArray
public java.lang.Object[] toArray()
Returns an array containing all of the elements in this list in the correct order.- Overrides:
toArrayin classjavax.swing.DefaultListModel- 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
-
-