public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals(CANCEL)) this.dispose(); if (e.getActionCommand().equals(OK)) { // Check password try { UserAccountDao uad2 = new UserAccountDaoImpl(); user = uad2.loginAuthorization(this.getUsername(), this.getPassword()); System.out.println("the user's email:" + user.getEmail() + "admin?:" + getIsAdmin()); model.setMyAccount(user); successfulLogin(); this.dispose(); } catch (PwdIncorrectException pie) { // pop up a window said incorrect password JOptionPane.showMessageDialog( null, "Incorrect password. Try again.", "Error Message", JOptionPane.ERROR_MESSAGE); passwordField.selectAll(); passwordField.setText(""); userName.setText(""); } catch (UserAccountNotFoundException uanfe) { // pop up a window said cannot find the user account JOptionPane.showMessageDialog( null, "User not exist. Try again.", "Error Message", JOptionPane.ERROR_MESSAGE); passwordField.selectAll(); passwordField.setText(""); userName.setText(""); } } }