edu.cs.ai.kreator.ui.gui.components.models
Class CheckboxListModel

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by javax.swing.DefaultListModel
          extended by edu.cs.ai.kreator.ui.gui.components.models.CheckboxListModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.ListModel

public class CheckboxListModel
extends javax.swing.DefaultListModel

A specialized data model for the CheckboxList. It extends the DefaultListModel by managing checkboxes for each item object and also has method getCheckedValues which returns all objects in the list which values are checked.

Author:
Tim Janus
See Also:
CheckboxList, Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
CheckboxListModel()
           
 
Method Summary
 void add(int index, java.lang.Object element)
           
 void addElement(java.lang.Object element)
           
 void addElement(java.lang.Object element, boolean checked)
           
 void addItemListener(java.awt.event.ItemListener listener)
          Registers an item listener to all checkboxes in the data model.
 void clear()
           
 javax.swing.JCheckBox getCheckbox(int index)
          Get the JCheckNox instance which is linked to the data object at the given index.
 javax.swing.JCheckBox getCheckbox(java.lang.Object element)
          Get the JCheckBox instance which is linked to the given element
 java.lang.Object[] getCheckedValues()
           
 java.lang.Object getElement(javax.swing.JCheckBox box)
           
 void insertElementAt(java.lang.Object element, int index)
           
 java.lang.Object remove(int index)
           
 void removeAllElements()
           
 boolean removeElement(java.lang.Object element)
           
 void removeElementAt(int index)
           
 void removeItemListener(java.awt.event.ItemListener listener)
          Unregisters a listener from all checkboxes in the data model.
 void removeRange(int indexStart, int indexEnd)
           
 
Methods inherited from class javax.swing.DefaultListModel
capacity, contains, copyInto, elementAt, elements, ensureCapacity, firstElement, get, getElementAt, getSize, indexOf, indexOf, isEmpty, lastElement, lastIndexOf, lastIndexOf, set, setElementAt, setSize, size, toArray, toString, trimToSize
 
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
 

Constructor Detail

CheckboxListModel

public CheckboxListModel()
Method Detail

getCheckbox

public javax.swing.JCheckBox getCheckbox(java.lang.Object element)
Get the JCheckBox instance which is linked to the given element

Parameters:
element - reference to the data object in the list.
Returns:
If element exists in the list: the linked JCheckBox otherwise null.

getCheckbox

public javax.swing.JCheckBox getCheckbox(int index)
Get the JCheckNox instance which is linked to the data object at the given index.

Parameters:
index - index of the data object.
Returns:
If the index is valid: the to the index linked JCheckBox otherwise null.

getElement

public java.lang.Object getElement(javax.swing.JCheckBox box)

getCheckedValues

public java.lang.Object[] getCheckedValues()
Returns:
all the data objects which linked checkboxes are select.

addItemListener

public void addItemListener(java.awt.event.ItemListener listener)
Registers an item listener to all checkboxes in the data model.

Parameters:
listener -

removeItemListener

public void removeItemListener(java.awt.event.ItemListener listener)
Unregisters a listener from all checkboxes in the data model.

Parameters:
listener -

add

public void add(int index,
                java.lang.Object element)
Overrides:
add in class javax.swing.DefaultListModel

addElement

public void addElement(java.lang.Object element)
Overrides:
addElement in class javax.swing.DefaultListModel

addElement

public void addElement(java.lang.Object element,
                       boolean checked)

insertElementAt

public void insertElementAt(java.lang.Object element,
                            int index)
Overrides:
insertElementAt in class javax.swing.DefaultListModel

clear

public void clear()
Overrides:
clear in class javax.swing.DefaultListModel

remove

public java.lang.Object remove(int index)
Overrides:
remove in class javax.swing.DefaultListModel

removeElement

public boolean removeElement(java.lang.Object element)
Overrides:
removeElement in class javax.swing.DefaultListModel

removeElementAt

public void removeElementAt(int index)
Overrides:
removeElementAt in class javax.swing.DefaultListModel

removeAllElements

public void removeAllElements()
Overrides:
removeAllElements in class javax.swing.DefaultListModel

removeRange

public void removeRange(int indexStart,
                        int indexEnd)
Overrides:
removeRange in class javax.swing.DefaultListModel