edu.cs.ai.kreator.ui.gui.components
Class CheckboxList

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JList
                  extended by edu.cs.ai.kreator.ui.gui.components.CheckboxList
All Implemented Interfaces:
CheckboxContainerComponent<CheckboxListModel>, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.Scrollable

public class CheckboxList
extends javax.swing.JList
implements CheckboxContainerComponent<CheckboxListModel>

Provides a list of checkboxes. Behind each checkbox a data object is saved. You can get an array of all data with selected checkboxes. This specialized list only works with a specialized Data-Model called CheckboxListModel

Author:
Tim Janus
See Also:
CheckboxListModel, Serialized Form

Nested Class Summary
protected  class CheckboxList.CellRenderer
          Inner class implementing a cellrenderer.
 
Nested classes/interfaces inherited from class javax.swing.JList
javax.swing.JList.AccessibleJList, javax.swing.JList.DropLocation
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected static javax.swing.border.Border noFocusBorder
           
 
Fields inherited from class javax.swing.JList
HORIZONTAL_WRAP, VERTICAL, VERTICAL_WRAP
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
CheckboxList()
          Ctor: Initialize the CheckboxList, register input listeners, register new cell renderer, create castModel.
 
Method Summary
 void addCheckboxChangeListener(java.awt.event.ItemListener listener)
          Adds an Itemlistener which fires each time a checkbox in the container changes.
 void checkAll(boolean checked)
          De/selects all checkboxes
 CheckboxListModel getCastModel()
           
 java.lang.Object[] getCheckedValues()
           
 void removeCheckboxChangeListener(java.awt.event.ItemListener listener)
          Removes an already registered item listeners.
 void setCheckboxLabel(java.lang.String label, int index)
          Change he checkbox label for the checkbox at a specific index.
 void setCheckboxLabels(java.util.List<java.lang.String> labels)
          Changes the labels of the checkboxes
 void setListData(java.lang.Object[] listData)
          Overrides default behavior creating an instance of CheckboxListModel which contains the data.
 void setListData(java.lang.Object[] listData, java.util.List<java.lang.String> texts)
          Sets new list data to the list but dont use default naming for the checkboxes (obj.ToString())
 void setListData(java.util.Vector<?> listData)
          Overrides default behavior creating an instance of CheckboxListModel which contains the data.
 void setModel(javax.swing.ListModel model)
          Checks if the given ListModel is of type CheckBoxList model if this is not the case it throws a ClassCastException.
 
Methods inherited from class javax.swing.JList
addListSelectionListener, addSelectionInterval, clearSelection, createSelectionModel, ensureIndexIsVisible, fireSelectionValueChanged, getAccessibleContext, getAnchorSelectionIndex, getCellBounds, getCellRenderer, getDragEnabled, getDropLocation, getDropMode, getFirstVisibleIndex, getFixedCellHeight, getFixedCellWidth, getLastVisibleIndex, getLayoutOrientation, getLeadSelectionIndex, getListSelectionListeners, getMaxSelectionIndex, getMinSelectionIndex, getModel, getNextMatch, getPreferredScrollableViewportSize, getPrototypeCellValue, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedIndex, getSelectedIndices, getSelectedValue, getSelectedValues, getSelectionBackground, getSelectionForeground, getSelectionMode, getSelectionModel, getToolTipText, getUI, getUIClassID, getValueIsAdjusting, getVisibleRowCount, indexToLocation, isSelectedIndex, isSelectionEmpty, locationToIndex, paramString, removeListSelectionListener, removeSelectionInterval, setCellRenderer, setDragEnabled, setDropMode, setFixedCellHeight, setFixedCellWidth, setLayoutOrientation, setPrototypeCellValue, setSelectedIndex, setSelectedIndices, setSelectedValue, setSelectionBackground, setSelectionForeground, setSelectionInterval, setSelectionMode, setSelectionModel, setUI, setValueIsAdjusting, setVisibleRowCount, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

noFocusBorder

protected static javax.swing.border.Border noFocusBorder
Constructor Detail

CheckboxList

public CheckboxList()
Ctor: Initialize the CheckboxList, register input listeners, register new cell renderer, create castModel.

Method Detail

getCheckedValues

public java.lang.Object[] getCheckedValues()
Specified by:
getCheckedValues in interface CheckboxContainerComponent<CheckboxListModel>
Returns:
An array of all user data which checkboxes are selected.

getCastModel

public CheckboxListModel getCastModel()
Specified by:
getCastModel in interface CheckboxContainerComponent<CheckboxListModel>
Returns:
The casted version of the used data-model.

addCheckboxChangeListener

public void addCheckboxChangeListener(java.awt.event.ItemListener listener)
Description copied from interface: CheckboxContainerComponent
Adds an Itemlistener which fires each time a checkbox in the container changes.

Specified by:
addCheckboxChangeListener in interface CheckboxContainerComponent<CheckboxListModel>
Parameters:
listener - Reference to the item listener.

removeCheckboxChangeListener

public void removeCheckboxChangeListener(java.awt.event.ItemListener listener)
Description copied from interface: CheckboxContainerComponent
Removes an already registered item listeners.

Specified by:
removeCheckboxChangeListener in interface CheckboxContainerComponent<CheckboxListModel>

setModel

public void setModel(javax.swing.ListModel model)
Checks if the given ListModel is of type CheckBoxList model if this is not the case it throws a ClassCastException. Also adds all the listeners to the new generated Model.

Overrides:
setModel in class javax.swing.JList
Throws:
java.lang.ClassCastException

setListData

public void setListData(java.lang.Object[] listData,
                        java.util.List<java.lang.String> texts)
Sets new list data to the list but dont use default naming for the checkboxes (obj.ToString())

Parameters:
listData - reference to an array of objects containing the data for the list.
texts - List of strings for name representation of the data.

setListData

public void setListData(java.lang.Object[] listData)
Overrides default behavior creating an instance of CheckboxListModel which contains the data.

Overrides:
setListData in class javax.swing.JList

setListData

public void setListData(java.util.Vector<?> listData)
Overrides default behavior creating an instance of CheckboxListModel which contains the data.

Overrides:
setListData in class javax.swing.JList

setCheckboxLabels

public void setCheckboxLabels(java.util.List<java.lang.String> labels)
Changes the labels of the checkboxes

Parameters:
labels - List of strings with new checkbox labels.

setCheckboxLabel

public void setCheckboxLabel(java.lang.String label,
                             int index)
Change he checkbox label for the checkbox at a specific index.

Parameters:
label - new label
index - index of the checkbox.

checkAll

public void checkAll(boolean checked)
Description copied from interface: CheckboxContainerComponent
De/selects all checkboxes

Specified by:
checkAll in interface CheckboxContainerComponent<CheckboxListModel>
Parameters:
checked - if true the checkboxes are select otherwise they are deselect.