Class CheckBoxListener

java.lang.Object
it.polimi.ingsw.Client.GUI.Listeners.CheckBoxListener
All Implemented Interfaces:
ItemListener, EventListener

public class CheckBoxListener extends Object implements ItemListener
Listener responsible for restricting the maximum number of checkboxes that can be selected
  • Field Details

    • maxCheckBoxesSelectable

      private final int maxCheckBoxesSelectable
      limit of selectable checkboxes
    • checkBoxes

      private final JCheckBox[] checkBoxes
      "listened" checkboxes
    • selectionCounter

      private int selectionCounter
      Selected checkboxes
  • Constructor Details

    • CheckBoxListener

      public CheckBoxListener(int limit, JCheckBox[] checkBoxes)
      Create a new checkBoxListener
      Parameters:
      limit - maximum number of selectable checkBoxes
      checkBoxes - checkboxes that will be listened by this listener
  • Method Details

    • itemStateChanged

      public void itemStateChanged(ItemEvent e)
      As soon as one checkbox has been selected, verify that selected checkBoxes are less than maximum
      Specified by:
      itemStateChanged in interface ItemListener
      Parameters:
      e - the event to be processed