private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed
        String userName = txtFieldUserName.getText();

        char[] pw = txtFieldPassword.getPassword();
        String password = new String(pw);

        userName.trim();
        password.trim();
        if(!userName.isEmpty() && !password.isEmpty()){

            if(user == null){
                

                User u = new User();

                u.setUsername(userName);
                u.setPassword(password, false);
                u.setRank((User.Rank)cmbBoxType.getSelectedItem());

                if(Controller.Instance().addUser(u)){
                    JOptionPane.showMessageDialog(this, "User saved");
                       this.dispose();
                }
                else{
                    lblError.setText("UserName already exsists");
                }
            }
            else{
                User u = new User();
                u.CopyUser(user);
                u.setUsername(userName);
                u.setPassword(password, false);

                u.setRank((User.Rank)cmbBoxType.getSelectedItem());

                if(Controller.Instance().ChangeUser(user, u))
                {
                    JOptionPane.showMessageDialog(this, "User saved");
                    this.dispose();
                }
                else{
                    lblError.setText("Change User failed username already exsists");
                }
            }
        }
        else{
            lblError.setText("Please enter a correct username and or password");
        }
    }//GEN-LAST:event_btnSaveActionPerformed