When I logged in to a textfile correct passcode is there still appears JOptionPane.lgnbb.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ee){ try{ File file = new File("Database.txt"); BufferedReader br = new BufferedReader(new FileReader(file)); String line = ""; while((line = br.readLine())!=null){ String acc[] = line.split("-"); String account = acc[0]; String passcode = acc[2]; if((txf1.getText().equals(account))&& (txf2.getText().equals(passcode))){ JOptionPane.showMessageDialog(null, "Login Success!!!", "Login Successfully!!!", JOptionPane.INFORMATION_MESSAGE); Administrator exe = new Administrator(); exe.adminAcc(); txf2.setText(""); } } } catch (IOException ex) { ex.printStackTrace(); } if((txf1.getText().equals(""))&& (txf2.getText().equals(""))) { JOptionPane.showMessageDialog(null, "Please Type!!", "Incomplete", JOptionPane.WARNING_MESSAGE); } else if(!(txf1.getText().equals(admin))|| !(txf2.getText().equals(adpass))) { JOptionPane.showMessageDialog(null, "Incorrect..\nPlease try again!", "Incorrect", JOptionPane.WARNING_MESSAGE); } if((txf1.getText().equals(admin))&& (txf2.getText().equals(adpass))){ JOptionPane.showMessageDialog(null, "Login Success!!!", "Login Successfully!!!", JOptionPane.INFORMATION_MESSAGE); Administrator exe = new Administrator(); exe.adminAcc(); txf2.setText(""); } } });