private void createNewGame(){
    int timer;
    //Checks if the two player name fields are within the length boundaries
     if (player1Name.getText ().length () >= TEXTFIELD_LIMIT ){
       player1Name.setForeground (Color.RED);
       JOptionPane.showMessageDialog (new JFrame (),"Player 1 name is too long, can be a maximum of "+TEXTFIELD_LIMIT+" characters");
       return;
     }
     else if (player2Name.getText ().length() >= TEXTFIELD_LIMIT){
       player2Name.setForeground (Color.RED);
       JOptionPane.showMessageDialog (new JFrame (),"Player2 name is too long, can be a maximum of "+TEXTFIELD_LIMIT+"characters");
       return;
     }
     //Creates the two player objects from the data occupying the form
    ViewPlayer player1 = new ViewPlayer(player1Name.getText(),
                        getDepth(player1DifficultyComboBox),
                        getIntFromDifficulty(player1DifficultyComboBox),
                        !isPlayerAI(player1TypeComboBox));
    
    ViewPlayer player2 = new ViewPlayer(player2Name.getText(),
                        getDepth(player2DifficultyComboBox),
                        getIntFromDifficulty(player2DifficultyComboBox),
                        !isPlayerAI(player2TypeComboBox));

    //Checks if the timer is selected, if its not it makes timer = -1, otherwise
    //it makes it equal to the time in the field in milliseconds
    if(!timerCheckBox.isSelected ()){
      timer = -1;}
    else{
      timer=Integer.parseInt ((String)timerDataCheckBox.getSelectedItem ());
      timer = (timer * 60) * 1000;
    }


    myParentWindow.initGame (player1,player2, timer);

    thisFrame.dispose ();

  }