@Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == sectionButton1) { //add a subsection
            if (sectionContentFlag == sectionContentState.NOSUB && sectionContentPanel.getComponentCount() != 0) {
                //the condition when there are still some questions in the section
                JOptionPane.showMessageDialog(sectionLabel, "Delete all the questions first!", "Attention", JOptionPane.ERROR_MESSAGE);

            } else if (sectionContentPanel.getComponentCount() >= 2) {
                //the condition that already have two subsecions
                JOptionPane.showMessageDialog(sectionLabel, "Already have two subsections!", "Attention", JOptionPane.ERROR_MESSAGE);

            } else {
                //add the subsections to the contentpanel
                SubsectionPanel subSectionPanel1 = new SubsectionPanel(exam_ID);

                subSectionPanel1.getGUI();
                sectionContentPanel.add(subSectionPanel1);
                sectionContentPanel.revalidate();
                sectionContentFlag = sectionContentState.TWOSUB;
            }

        } else if (e.getSource() == sectionButton2) {//add a question
            if (sectionContentFlag == sectionContentState.TWOSUB && sectionContentPanel.getComponentCount() != 0) {
                //the condtion that still some subsection exist in the section
                JOptionPane.showMessageDialog(sectionLabel, "Delete all the subsections first!", "Attention", JOptionPane.ERROR_MESSAGE);

            } else {
                //set the contentflag and open the choose question panel
                sectionContentFlag = sectionContentState.NOSUB;
                ChooseQuestionsPanel chooseQuestionsPanel = new ChooseQuestionsPanel((SectionPanel)this);
                chooseQuestionsPanel.setVisible(true);
            }

        }
    }