Class CheckBoxArray

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class CheckBoxArray extends JPanel
A panel containing a fixed number of checkboxes, laid out either horizontally or vertically. State is read and written as a BitSet. Registered listeners are notified whenever any checkbox changes state.
See Also:
  • Constructor Details

    • CheckBoxArray

      public CheckBoxArray(int count, boolean vertical)
      Creates a new CheckBoxArray.
      Parameters:
      count - number of checkboxes to create
      vertical - true for vertical, false for horizontal
  • Method Details

    • addListener

      public void addListener(Runnable listener)
      Registers a listener called on any checkbox state change.
      Parameters:
      listener - the callback to register
    • getState

      public BitSet getState()
      Returns the current checkbox states as a BitSet. Bit i is set iff checkbox i is selected.
      Returns:
      a fresh snapshot of the current state
    • setState

      public void setState(BitSet state)
      Sets checkbox states from a BitSet. Bit i of state drives checkbox i. Only changed boxes are updated; listeners are not fired.
      Parameters:
      state - source BitSet