public void createNewTask(JTable tableAllTask, JList listUsersOnTask, JCheckBox checkBoxSub, JTextField textFieldTaskName, JComboBox comboBoxType, JComboBox comboBoxStatus,
            JTextField textFieldCustomer, JComboBox comboBoxTaskLeader, JDateChooser dateChooserExpectedStart, JDateChooser dateChooserExpectedEnd,
            JTextField textFieldEstimatedTime, JComboBox comboBoxPriority, JTextArea textAreaDescription) throws ParseException, SQLException, IOException {

        DefaultTableModel modelTable = (DefaultTableModel) tableAllTask.getModel();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

        Type type = (Type) comboBoxType.getSelectedItem();
        Statuss status = (Statuss) (comboBoxStatus.getSelectedItem());
        Customer customer = null;
        User user = (User) comboBoxTaskLeader.getSelectedItem();
        String taskName = textFieldTaskName.getText();
        String taskDescription = textAreaDescription.getText();
        int taskID;
        int estimatedTime = Integer.parseInt(textFieldEstimatedTime.getText());
        int priority = Integer.parseInt(comboBoxPriority.getSelectedItem().toString());
        Date taskStartDate = dateChooserExpectedStart.getDate();
        Date taskEndDate = dateChooserExpectedEnd.getDate();

        for (int i = 0; i < Controller.customerList.size(); i++) {
            if (Controller.customerList.get(i).getCustomerID() == Integer.parseInt(textFieldCustomer.getText())) {
                customer = Controller.customerList.get(i);
            }
        }

        if (taskName.isEmpty()) {
            JOptionPane.showMessageDialog(null, "Der er opstået en fejl ! Er alle felter med stjerne udfyldt? Og er den valgte slut dato efter start dato?", "Fejlrapport", JOptionPane.WARNING_MESSAGE);
        } else if (checkBoxSub.isSelected()) {
            Date ParentStartDate = sdf.parse(modelTable.getValueAt(tableAllTask.getSelectedRow(), 7).toString());
            Date ParentEndDate = sdf.parse(modelTable.getValueAt(tableAllTask.getSelectedRow(), 8).toString());
            Boolean taskChecker = subTaskDateChecker(taskStartDate, taskEndDate, ParentStartDate, ParentEndDate);

            if (tableAllTask.getSelectedRow() != -1 && taskChecker) {
                taskID = Integer.parseInt(modelTable.getValueAt(tableAllTask.getSelectedRow(), 0).toString());

                Task task = new Task(taskName,
                        taskID,
                        type,
                        status,
                        customer,
                        user,
                        taskStartDate,
                        taskEndDate,
                        estimatedTime,
                        priority,
                        taskDescription);

                dbHandler.createSubTask(task);
                dbHandler.addUserToTask(listUsersOnTask);

            } else {
                JOptionPane.showMessageDialog(null, "Der ikke valgt nogen opgave at lav delopgave til eller den valgte dato ikke er inde for opgaven", "Fejlrapport", JOptionPane.WARNING_MESSAGE);
            }
        } else if (!checkBoxSub.isSelected()) {

            Task task = new Task(taskName,
                    type,
                    status,
                    customer,
                    user,
                    taskStartDate,
                    taskEndDate,
                    estimatedTime,
                    priority,
                    taskDescription);
            Controller.dbHandler.createTask(task);
            createNewTimeSpentOnTaskWithUserOnTaskList(listUsersOnTask);
            // Controller.dbHandler.addUserToTask(listUsersOnTask);
        }

    }