@Override
        /*
         * actionPerformed is used for the login button
         * gets the username and to fields and sets them to
         * username and connectedTo variables
         * then remoes the login panel
         * and refreshes the layout
         * then calls the initChatComponents
         */
        public void actionPerformed(ActionEvent e) {
            if(debug){
                System.out.println("Login button clicked");
            }
            /*
             * Check to see if both of the fields have strings in them
             * make sure they are not empty strings nor the prepopulated strings!
             */
            if(!usernameField.getText().equals("")
                    &&!usernameField.getText().equals("Please type your username here")
                    &&!toField.getText().equals("")
                    &&!toField.getText().equals("Please type other person's username here")){
                //Set the variables to the new strings
                username = usernameField.getText();
                connectedTo = toField.getText();
                
                /*
                 * Strip unwanted characters
                 * \W for anything that is not a word character
                 * \s for anything that is a space character
                 * note that is is capital W and lower case s
                 */
                username = username.replaceAll("\\W","");
                username = username.replaceAll("\\s","");
                connectedTo = connectedTo.replaceAll("\\W","");
                connectedTo = connectedTo.replaceAll("\\s","");
                try{
                    //Remove the loginPanel
                    remove(loginPanel);
                    refreshLayout();
                    initChatComponents();
                }catch(Exception e2){
                    System.out.println("Exception while trying to change the layout: "+e2);
                }
            }else{
                //If no username is set, warn the user
                if(usernameField.getText().equals("")){
                    usernameField.setText("Please type your username here");
                }
                //If no other person's username is set, warn the user
                if(toField.getText().equals("")){
                   toField.setText("Please type other person's username here"); 
                }
            }
        }