private void updatePasswordButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updatePasswordButtonActionPerformed
        
        // If fields are empty
        if (passwordText.getText().equals("") || confirmPasswordText.getText().equals(""))
        {
            JOptionPane.showMessageDialog(null, "Password fields can not be empty! Please try again!");
        }
        // or if fields dont match
        else if (!passwordText.getText().equals(confirmPasswordText.getText()))
        {
            JOptionPane.showMessageDialog(null, "The password fields do not match! Please try again!");
        }
        else
        {
            //hash the password
        //MessageDigest handles hashing in various forms
        MessageDigest md;
        //declare the password hashed string
        String hashedPassword="";
        try {
            //set the hash type to SHA256
            md = MessageDigest.getInstance("SHA-256");
            //retrieve the text from the password field
            String text = passwordText.getText();
            try {
                //encode the hash in UTF8, to match the DB
                md.update(text.getBytes("UTF-8")); 
            } catch (UnsupportedEncodingException e) {
                System.out.println(e);
            }
            //hashed password in raw HEX
            byte[] hashedP = md.digest();
            //convert the raw data to a string, directly comparable to DB string
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < hashedP.length; ++i) {
            sb.append(Integer.toHexString((hashedP[i] & 0xFF) | 0x100).substring(1,3));
            }
            hashedPassword= sb.toString();            
        } catch (NoSuchAlgorithmException ex) {
            System.out.println(ex);
        }
        //end of hashing
        //Connect to DB and change password to new hashed password
        Helper.openConnection();
        boolean updateSuccess = Helper.updateDatabase("UPDATE tstaff SET password='"+hashedPassword+"' WHERE staffid='"+usernameComboBox.getSelectedItem().toString()+"'");
        if (updateSuccess)
        {
            JOptionPane.showMessageDialog(null, "Successfully updated password");
        }
        }
        // Clear elements
        usernameComboBox.setSelectedIndex(-1);
        passwordText.setText("");
        confirmPasswordText.setText("");
    }//GEN-LAST:event_updatePasswordButtonActionPerformed