Class CheckBoxArray
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
edu.cnu.mdi.component.checkboxarray.CheckBoxArray
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,Accessible
Multi-column panel of check boxes and optional radio-button groups.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Hashtable<String, ButtonGroup> protected final Hashtable<String, AbstractButton> Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionCheckBoxArray(int numColumns, int hgap, int vgap) Create an empty check box array with the given column layout.CheckBoxArray(int numColumns, int hgap, int vgap, String... labels) Create a check box array pre-populated with one unchecked, enabled, ungrouped check box per label, in black text with no item listener. -
Method Summary
Modifier and TypeMethodDescriptionadd(String label, boolean initialState, boolean enabled, long bits, long mask, ItemListener itemListener, Color textColor) Conditionally add an ungrouped check box, gated by a bitmask test.add(String label, boolean initialState, boolean enabled, ItemListener itemListener, Color textColor) Add an ungrouped check box, placed in the next column in round-robin order (seeadd(String, boolean, boolean, String, ItemListener, Color)).add(String label, boolean initialState, boolean enabled, String buttonGroupName, ItemListener itemListener, Color textColor) Add a check box, optionally as part of a mutually-exclusive (radio-button-like) group.getActiveButton(String buttonGroupName) booleanbooleanisSelected(String label) voidsetEnabled(String label, boolean enabled) Set a check box's enabled state; a no-op if no box has this label.voidsetSelected(String label, boolean selected) Set a check box's checked state; a no-op if no box has this label.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods 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, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, updateMethods 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, transferFocusDownCycle, validate, validateTreeMethods 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
buttonGroups
-
buttons
-
-
Constructor Details
-
CheckBoxArray
public CheckBoxArray(int numColumns, int hgap, int vgap) Create an empty check box array with the given column layout.- Parameters:
numColumns- number of columns; must be positivehgap- horizontal gap in pixels between columnsvgap- vertical gap in pixels between check boxes within a column; negative values are clamped to zero- Throws:
IllegalArgumentException- ifnumColumnsis not positive
-
CheckBoxArray
Create a check box array pre-populated with one unchecked, enabled, ungrouped check box per label, in black text with no item listener.- Parameters:
numColumns- number of columns; must be positivehgap- horizontal gap in pixels between columnsvgap- vertical gap in pixels between check boxes within a column; negative values are clamped to zerolabels- labels of the check boxes to add, one per box- Throws:
IllegalArgumentException- ifnumColumnsis not positive
-
-
Method Details
-
add
public CheckBoxData add(String label, boolean initialState, boolean enabled, ItemListener itemListener, Color textColor) Add an ungrouped check box, placed in the next column in round-robin order (seeadd(String, boolean, boolean, String, ItemListener, Color)).- Parameters:
label- the check box's label and lookup keyinitialState- initial checked stateenabled- initial enabled stateitemListener- listener notified of check/uncheck events, ornullfor nonetextColor- label text color- Returns:
- the new check box's data holder
-
add
public CheckBoxData add(String label, boolean initialState, boolean enabled, long bits, long mask, ItemListener itemListener, Color textColor) Conditionally add an ungrouped check box, gated by a bitmask test.The check box is added only when
(bits & mask) == mask(i.e. every bit inmaskis set inbits|); otherwise nothing is added and this method returnsnullwithout error.- Parameters:
label- the check box's label and lookup keyinitialState- initial checked stateenabled- initial enabled statebits- the feature-flag bits to testmask- the bits that must all be set inbitsfor the check box to be addeditemListener- listener notified of check/uncheck events, ornullfor nonetextColor- label text color- Returns:
- the new check box's data holder, or
nullif(bits & mask) != mask
-
add
public CheckBoxData add(String label, boolean initialState, boolean enabled, String buttonGroupName, ItemListener itemListener, Color textColor) Add a check box, optionally as part of a mutually-exclusive (radio-button-like) group.Check boxes are placed into columns in round-robin order: each call places its box in the next column after the previous call's, wrapping back to the first column after the last.
- Parameters:
label- the check box's label and lookup key (used bygetButton(java.lang.String),isSelected(java.lang.String), etc.)initialState- initial checked stateenabled- initial enabled statebuttonGroupName- name of the mutually-exclusive group to join, ornullfor an ungrouped (independent) check boxitemListener- listener notified of check/uncheck events, ornullfor nonetextColor- label text color- Returns:
- the new check box's data holder
-
getActiveButton
- Parameters:
buttonGroupName- name of a group previously used withadd(String, boolean, boolean, String, ItemListener, Color)- Returns:
- the currently-selected button in that group, or
nullif the group doesn't exist or has no selection
-
setSelected
Set a check box's checked state; a no-op if no box has this label.- Parameters:
label- the check box's labelselected- the new checked state
-
isSelected
- Parameters:
label- the check box's label- Returns:
trueif a box with this label exists and is checked
-
isEnabled
- Parameters:
label- the check box's label- Returns:
trueif a box with this label exists and is enabled
-
setEnabled
Set a check box's enabled state; a no-op if no box has this label.- Parameters:
label- the check box's labelenabled- the new enabled state
-
getButton
- Parameters:
label- the check box's label- Returns:
- the button with this label, or
nullif none exists
-