确定 itemListener 中 JCheckBox 的标识

determine identification of a JCheckBox in itemListener

我有 4 个复选框,用户可以 select 或取消 select 它们以进行所需的设置,但是,程序需要至少选中 1 个复选框才能生成用户所需的信息。如果用户取消选中最后一个剩余的复选框,我希望程序为他们重新选中它,但为了做到这一点,我需要获得他们选中的最后一个复选框,我该如何识别他们在itemListener?

private class HandlerClass implements ItemListener {
    public void itemStateChanged(ItemEvent e){
        if (atLeastOneBoxChecked()){
            generationSettings.includeAZLowerCaseChars(azCheck.isSelected());
            generationSettings.includeAZUpperCaseChars(AZCheck.isSelected());
            generationSettings.include09Chars(o9Check.isSelected());
            generationSettings.includeSpecialChars(specialCheck.isSelected());
        } else{
            // reset unchecked box to checked
        }
    }

    public boolean atLeastOneBoxChecked(){
        return azCheck.isSelected() || AZCheck.isSelected() || o9Check.isSelected() || specialCheck.isSelected();
    }
}

how might I go about identifying which specific checkbox they checked within the itemListener?

ItemEventgetSource() 方法将包含复选框:

JCheckBox checkBox = (JCheckBox)e.getSource();