Advertisement
Guest User

Untitled

a guest
Jul 14th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.08 KB | None | 0 0
  1. private void save() {
  2.         if (!validatePassword()) {
  3.             return;
  4.         }
  5.        
  6.         User user = Session.getInstance().getUser();
  7.         user.setPassword(String.valueOf(newPasswordField.getPassword()));
  8.        
  9.         try {
  10.             UserDao service = new UserDaoImpl();
  11.             service.update(user);
  12.             showSucceed("Password berhasil diganti");
  13.         } catch (SQLException e) {
  14.             showWarning("Password gagal diganti");
  15.         }
  16.     }
  17.    
  18.     private boolean validatePassword() {
  19.         String password = String.valueOf(newPasswordField.getPassword());
  20.        
  21.         if (password.isEmpty()) {
  22.             showWarning("Password masih kosong");
  23.             return false;
  24.         }
  25.        
  26.         return true;
  27.     }
  28.    
  29.     private void showWarning(String message) {
  30.         JOptionPane.showMessageDialog(this, message, "Sukses", JOptionPane.ERROR_MESSAGE);
  31.     }
  32.    
  33.     private void showSucceed(String message) {
  34.         JOptionPane.showMessageDialog(this, message, "Gagal", JOptionPane.INFORMATION_MESSAGE);
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement