Guest User

Untitled

a guest
Oct 30th, 2016
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1.   private void btnLoginActionPerformed(java.awt.event.ActionEvent evt) {                                        
  2.  
  3.         String sUsername = tfUser.getText();
  4.         String sPassword = pfPass.getText();
  5.         boolean ValidLogin = false;
  6.  
  7.         try (Scanner file = new Scanner(new File("LoginDetails.txt"))) {
  8.             while (file.hasNext()) {
  9.                 String next = file.nextLine();
  10.                 String[] arr = next.split("/");
  11.                 if (arr[0].equals(sUsername && arr[1].equals(sPassword)) {
  12.                         this.setVisible(false);
  13.                    
  14.             }else {
  15.                     ValidLogin = false;
  16.                 }
  17.             }
  18.             }
  19.            
  20.  
  21.         } catch (Exception e) {
  22.             JOptionPane.showMessageDialog(this, "Incorrect Username or Password");
  23.         }
  24.         if (ValidLogin== true) {
  25.                                 this.setVisible(false);
  26.                     new GameScreen().setVisible(true);
  27.         }
  28.     }
Add Comment
Please, Sign In to add comment