@Override
    public void actionPerformed(ActionEvent e) {
      if (e.getSource() == btnReset) {
        // If reset selected student's password
        int index = studentsTable.getSelectedRow();

        // Check if selected a student
        if (index >= 0) {
          Student student = students.get(index);
          String newPassword = student.setRandomPassword();
          student.setResetPassRequested(false);

          // Check database update status
          if (FWCConfigurator.getDbConn().updateStudent(student)) {
            // Popup with new password
            JOptionPane.showMessageDialog(
                null,
                student.getUsername()
                    + "'s password has been successfully "
                    + "reset to:\n"
                    + newPassword,
                "Password Reset Successful",
                JOptionPane.INFORMATION_MESSAGE);
          } else {
            JOptionPane.showMessageDialog(
                null,
                "Student could " + "not be updated in the database.",
                "Student Update Failed",
                JOptionPane.ERROR_MESSAGE);
          }
        } else { // No student is selected from the table
          JOptionPane.showMessageDialog(
              null,
              "Please select a " + "student" + " from the table first.",
              "Reset Password Error",
              JOptionPane.INFORMATION_MESSAGE);
        }
      }
      // If reset all students' passwords
      else if (e.getSource() == btnResetAll) {
        StringBuilder message =
            new StringBuilder("The following " + "students' passwords have been reset.\n");
        message.append(
            "Please keep the new passwords in a "
                + "safe place.\n\nUsername Password\n"
                + "-------- --------");
        String newPassword;
        boolean error = false;
        int count = 0;

        for (Student student : students) {
          newPassword = student.setRandomPassword();
          student.setResetPassRequested(false);

          // Check database update status
          if (!FWCConfigurator.getDbConn().updateStudent(student)) {
            JOptionPane.showMessageDialog(
                null,
                "Student could not be updated in the database.",
                "Student Update Failed",
                JOptionPane.ERROR_MESSAGE);
            error = true;
            break;
          } else {
            message.append("\n").append(student.getUsername()).append(": ").append(newPassword);
            count++;
          }
        }

        if (!error || count > 0) {
          // Popup with new passwords
          JOptionPane.showMessageDialog(
              null,
              message.toString(),
              "Password Reset Successful",
              JOptionPane.INFORMATION_MESSAGE);
        }
      }

      refresh();
    }