private void createActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createActionPerformed
        //User pressed the create button
        if (!isEdited()) {
            //If nothing was changed then close window
            this.setVisible(false);
            dispose();
        } else {
            //A field was changed
            if (meetsRequired()) {
                //Check if all required fields are filled in
                if (checkFields()) {
                    //check fields for proper format and data
                    TrainingClass newTrainingClass = new TrainingClass();

                    //Set name
                    newTrainingClass.setName(name.getText());

                    //Set gym
                    newTrainingClass.setGymID(getSelectedGym().getId());

                    //Find trainer selected and set 
                    String[] split = trainer.getSelectedItem().toString().split("\\s");
                    for (User train : getTrainerList()) {
                        if ((train.getFirstName().equals(split[0])) && (train.getLastName().equals(split[1]))) {
                            newTrainingClass.setTrainer(train);
                        }
                    }

                    //Set start and end times
                    newTrainingClass.setStartTime(getStartTime());
                    newTrainingClass.setEndTime(getEndTime());

                    //Set some field values
                    newTrainingClass.setComments(comments.getText());
                    newTrainingClass.setLevel(level.getSelectedItem().toString());
                    newTrainingClass.setWorkoutDetails(details.getText());
                    newTrainingClass.setMaxCapacity(Integer.parseInt(maxCapacity.getText()));
                    
                    //Set price
                    if (!price.getText().equals("")) {
                    //if a price is specified
                        Pattern pattern = Pattern.compile("(\\$)?(\\d*)(\\.\\d{2})?");
                        Matcher matcher = pattern.matcher(price.getText());
                        matcher.matches();

                        newTrainingClass.setPrice(Double.parseDouble((matcher.group(2) + matcher.group(3))));
                    } 
                    else {
                    //Default price since the field is not required
                        newTrainingClass.setPrice(0.0);
                    }

                    //Class is not canceled when created by default
                    newTrainingClass.setCanceled(false);

                    //Save class
                    if (!MongoHelper.save(newTrainingClass, "trainingClasses")) {
                    //If save failed notify user
                        JOptionPane.showMessageDialog(this, "Save Error!\nPlease try again.", "Create Training Class - Error", JOptionPane.ERROR_MESSAGE, null);
                    } 
                    else {
                    //Save was successful so notify the user and close window
                        this.setVisible(false);
                        dispose();
                        JOptionPane.showMessageDialog(this, "Training Class Created Successfully!", "Create Training Class - Success", JOptionPane.PLAIN_MESSAGE, null);
                    }
                }
            } 
            else {
            //If not all required fields are filled in
                JOptionPane.showMessageDialog(this, "Not all required fields are filled out!\nPlease try again.", "Create Gym - Error", JOptionPane.ERROR_MESSAGE, null);
            }
        }
    }//GEN-LAST:event_createActionPerformed