org.formaria.swing
Class CheckList

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 org.formaria.swing.List
                      extended by org.formaria.swing.CheckList
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.ListSelectionListener, javax.swing.Scrollable, ErrorDisplay, ListenerHelper, ListHolder

public class CheckList
extends List
implements java.awt.ItemSelectable

A list box that contains a list of check boxes

Copyright (c) Formaria Ltd., 2001-2008, This software is licensed under the GNU Public License (GPL), please see license.txt for more details. If you make commercial use of this software you must purchase a commercial license from Formaria.

$Revision: 1.8 $

See Also:
Serialized Form

Nested Class Summary
 
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
 
Fields inherited from class org.formaria.swing.List
errorMessage, errorStatus, invoker, listModel
 
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
CheckList()
          Create a new checked list
CheckList(java.lang.Object[] items)
          Create a new checked list
 
Method Summary
 void addItem(java.lang.Object obj)
          Add an item to the listmodel
 void addItemListener(java.awt.event.ItemListener l)
          Adds an ItemListener to the checkbox.
 void enableItem(int idx, boolean selected)
          Enable the selection of an item in the list
protected  void fireItemStateChanged(java.awt.event.ItemEvent event)
          Notifies all listeners that have registered interest for notification on this event type.
 java.lang.String[] getSelectedItems()
          Get a list of the checked items in the list
 java.lang.Object[] getSelectedObjects()
          Get the selected objects
 int getSelectionMode()
          Get the list selection mode.
 boolean isItemChecked(int idx)
          Get the checked state of the indexed item
 void removeItemListener(java.awt.event.ItemListener l)
          Removes an ItemListener from the button.
 void selectItem(int idx, boolean selected)
          Force the selection of an item in the list
 void setAltUnselectedColors(java.awt.Color frgd, java.awt.Color bkgd)
          Set the colors for alternate ( odd ) row colors
 void setBorderStyle(java.lang.String style)
          Set the border style
 void setCellRenderer(javax.swing.ListCellRenderer cellRenderer)
          Sets the delegate that is used to paint each cell in the list.
 void setDefaultSelection()
          Set the list to its default selection state
 void toggleAll(boolean select)
          Select/unselect all the items in the list
 
Methods inherited from class org.formaria.swing.List
addHandler, getItemCount, getSelectedObject, paint, removeAll, select, select, setDragEnabled, setErrorMessage, setErrorStatus, setRenderer, setRendererClass, setSelectedObject, setSelectedObjects, valueChanged
 
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, getSelectionModel, getToolTipText, getUI, getUIClassID, getValueIsAdjusting, getVisibleRowCount, indexToLocation, isSelectedIndex, isSelectionEmpty, locationToIndex, paramString, removeListSelectionListener, removeSelectionInterval, setDropMode, setFixedCellHeight, setFixedCellWidth, setLayoutOrientation, setListData, setListData, setModel, 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, 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, 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
 
Methods inherited from interface org.formaria.aria.ListHolder
getSelectedIndex
 

Constructor Detail

CheckList

public CheckList()
Create a new checked list


CheckList

public CheckList(java.lang.Object[] items)
Create a new checked list

Parameters:
items - an array of items to add to the list
Method Detail

setDefaultSelection

public void setDefaultSelection()
Set the list to its default selection state

Specified by:
setDefaultSelection in interface ListHolder
Overrides:
setDefaultSelection in class List

addItem

public void addItem(java.lang.Object obj)
Add an item to the listmodel

Specified by:
addItem in interface ListHolder
Overrides:
addItem in class List
Parameters:
obj - the item to be added

setAltUnselectedColors

public void setAltUnselectedColors(java.awt.Color frgd,
                                   java.awt.Color bkgd)
Set the colors for alternate ( odd ) row colors

Parameters:
frgd - the foreground color
bkgd - the background color

setCellRenderer

public void setCellRenderer(javax.swing.ListCellRenderer cellRenderer)
Sets the delegate that is used to paint each cell in the list. The job of a cell renderer is discussed in detail in the class level documentation.

If the prototypeCellValue property is non-null, setting the cell renderer also causes the fixedCellWidth and fixedCellHeight properties to be re-calculated. Only one PropertyChangeEvent is generated however - for the cellRenderer property.

The default value of this property is provided by the ListUI delegate, i.e. by the look and feel implementation.

This is a JavaBeans bound property.

Overrides:
setCellRenderer in class javax.swing.JList
Parameters:
cellRenderer - the ListCellRenderer that paints list cells
See Also:
JList.getCellRenderer()

getSelectedObjects

public java.lang.Object[] getSelectedObjects()
Description copied from interface: ListHolder
Get the selected objects

Specified by:
getSelectedObjects in interface java.awt.ItemSelectable
Specified by:
getSelectedObjects in interface ListHolder
Overrides:
getSelectedObjects in class List
Returns:
the selected objects in the list

getSelectedItems

public java.lang.String[] getSelectedItems()
Get a list of the checked items in the list

Returns:
the checked items

enableItem

public void enableItem(int idx,
                       boolean selected)
Enable the selection of an item in the list

Parameters:
idx - the index of the item
selected - true to force selection of the item

selectItem

public void selectItem(int idx,
                       boolean selected)
Force the selection of an item in the list

Parameters:
idx - the index of the item
selected - true to force selection of the item

isItemChecked

public boolean isItemChecked(int idx)
Get the checked state of the indexed item

Parameters:
idx - the index of the item
Returns:
true if the item is checked

toggleAll

public void toggleAll(boolean select)
Select/unselect all the items in the list

Parameters:
select - true to select the items, false to unselect

getSelectionMode

public int getSelectionMode()
Get the list selection mode. This component returns 2. The selection corresponds to the items that are checked and not the items that are highlighted.

Specified by:
getSelectionMode in interface ListHolder
Overrides:
getSelectionMode in class javax.swing.JList
Returns:
  • 0=ListSelectionModel.SINGLE_SELECTION,
  • 1=ListSelectionModel.SINGLE_INTERVAL_SELECTION,
  • 2=ListSelectionModel.MULTIPLE_INTERVAL_SELECTION

setBorderStyle

public void setBorderStyle(java.lang.String style)
Set the border style

Parameters:
style - 0 to turn off the border

addItemListener

public void addItemListener(java.awt.event.ItemListener l)
Adds an ItemListener to the checkbox.

Specified by:
addItemListener in interface java.awt.ItemSelectable
Parameters:
l - the ItemListener to be added

removeItemListener

public void removeItemListener(java.awt.event.ItemListener l)
Removes an ItemListener from the button.

Specified by:
removeItemListener in interface java.awt.ItemSelectable
Parameters:
l - the ItemListener to be removed

fireItemStateChanged

protected void fireItemStateChanged(java.awt.event.ItemEvent event)
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the event parameter.

Parameters:
event - the ItemEvent object
See Also:
EventListenerList