@Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource()==submitButton) {
            if (sectionPanel.submitSection()) {//if submit succeed
                JFrame rootFrame=(JFrame)scrollPane.getRootPane().getParent();
                //rootFrame.dispose();
                //this.dispose();
                Exam exam=new Exam(examId);
                rootFrame.setContentPane(exam.getGUI());
                rootFrame.revalidate();
                rootFrame.repaint();
                //exam.setVisible(true);
            }

            
        }else if (e.getSource()==updateButton) {
            if (sectionPanel.updateSection()) {//if update succeed
              
                JFrame rootFrame=(JFrame)scrollPane.getRootPane().getParent();
                //rootFrame.dispose();
                //this.dispose();
                Exam exam=new Exam(examId);
                rootFrame.setContentPane(exam.getGUI());
                rootFrame.revalidate();
                rootFrame.repaint();
                //exam.setVisible(true);
            }
        }else if (e.getSource()==cancelButton) {
            //remove current panel when calbutton
            scrollPane.setVisible(false);
            scrollPane.getParent().remove(scrollPane);
            scrollPane.invalidate();
                
              
        }
    }