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);
        String errorMessage = "";
        
        if(userName.isEmpty()){
            errorMessage = "*  Please enter a username <br>";
        }
        if((user == null) && (password.isEmpty())){
            errorMessage += "*  Please enter a password <br>";
        }
        
        userName.trim();
        password.trim();
        if ("".equals(errorMessage)) {
            if (user == null) {
                User u = new User();
                u.setUsername(userName);
                u.setPassword(password, true);
                u.setRank((Rank) cmbBoxType.getSelectedItem());

                if (Controller.Instance().save(u)) {
                    JOptionPane.showMessageDialog(this, "User \"" + u.getUsername() + "\" saved");
                    this.dispose();
                } else {
                    lblError.setText("*  UserName already exsists");
                }
            } else {
                user.setUsername(userName);
                if(!password.isEmpty()){
                    user.setPassword(password, true);
                }
                user.setRank((Rank) cmbBoxType.getSelectedItem());

                if (Controller.Instance().update(user)) {
                    JOptionPane.showMessageDialog(this, "User \"" + user.getUsername() + "\" saved");
                    this.dispose();
                } else {
                    lblError.setText("*  Change User failed username already exsists");
                }
            }
        } else {
            lblError.setText("<html> "+ errorMessage + " </html>");
        }
    }//GEN-LAST:event_btnSaveActionPerformed