private void setMainPanel() {
        //getsections according to examId
        getSections(examId);

        sectionChosen = new JCheckBox[sections.size()];

        sectionLabels = new JLabel[sections.size()];

        //set editbuttons, editbuttons and sectionlabels
        for (int i = 1; i < sections.size() + 1; i++) {
            Section section = sections.get(i - 1);
            String sectionTimeLimit = new SimpleDateFormat("HH:mm:ss").format(section.getTimeLimit());

            sectionLabels[i - 1] = new JLabel("Section " + i + "  " + section.getSection_Name());
            //Edit Button

            //Checkboxes
            sectionChosen[i - 1] = new JCheckBox();
            sectionChosen[i - 1].setName(section.getSection_ID() + "");
            sectionChosen[i - 1].addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    JCheckBox cbLog = (JCheckBox) e.getSource();

                    if (cbLog.isSelected()) {
                        for (int i = 0; i < sectionChosen.length; i++) {
                            if (!(sectionChosen[i] == e.getSource())) {
                                sectionChosen[i].setEnabled(false);
                            }
                        }
                    } else {
                        for (int i = 0; i < sectionChosen.length; i++) {
                            sectionChosen[i].setEnabled(true);
                        }
                    }
                }
            });

        }

        //p2.setLayout(new GridLayout(sections.size(),3));
        //setlayout
        GroupLayout groupLayout;
        GroupLayout.ParallelGroup horizontalGroup_P;
        GroupLayout.SequentialGroup verticalGroup_S;

        groupLayout = new GroupLayout(mainPanel);
        groupLayout.setAutoCreateContainerGaps(true);
        groupLayout.setAutoCreateGaps(true);

        horizontalGroup_P = groupLayout.createParallelGroup();
        verticalGroup_S = groupLayout.createSequentialGroup();

        for (int i = 0; i < sections.size(); i++) {
//            mainPanel.add(sectionLabels[i]);
//            mainPanel.add(buttons[i]);
//            mainPanel.add(deleteButtons[i]);
            horizontalGroup_P.addGroup(groupLayout.createSequentialGroup()
                    .addComponent(sectionChosen[i])
                    .addComponent(sectionLabels[i])
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE));

            verticalGroup_S.addGroup(groupLayout.createParallelGroup()
                    .addComponent(sectionChosen[i])
                    .addComponent(sectionLabels[i]));

        }
        groupLayout.setHorizontalGroup(horizontalGroup_P);
        groupLayout.setVerticalGroup(verticalGroup_S);
        mainPanel.setLayout(groupLayout);
        mainPanel.revalidate();
        //p2.repaint();

    }