エラーが発生しましたが、それがどこから来ているのかわかりませんか? ここに問題があると思います:
public boolean verifyLogin(String username, String password)
{
//method to check if the Login details math those in the text file
//Parameters are the username and password used to verify login
//returns a boolean to indicate whether the login is legitimate
boolean flag = false;
try
{
Scanner sc = new Scanner(new FileReader("src\\Users.txt"));
while (sc.hasNext())
{
Scanner b = new Scanner(sc.nextLine()).useDelimiter("#");
String uName = sc.next();
String pWord = sc.next();
if (username.equalsIgnoreCase(uName) & password.equalsIgnoreCase(pWord))
{
JOptionPane.showMessageDialog(null, "Login Successfull. /n Welcome");
flag = true;
}
else
{
JOptionPane.showMessageDialog(null, "Login Unsuccessfull. /n Please re-enter your details");
flag = false;
}
}
}
catch (FileNotFoundException ex)
{
System.out.println("File was not found " + ex.getMessage() );
}
return flag;
}
これはアクション メソッドに対応します。
private void LoginButtonActionPerformed(java.awt.event.ActionEvent evt)
{
GuiClass gC = new GuiClass();
Welcome w = new Welcome();
boolean f = gC.verifyLogin(UsernameField.getText(), PasswordField.getText());
if (f = true)
{
this.setVisible(false);
w.setVisible(true);
}
else
{
System.out.println("It works");
}
}
エラーの原因を突き止めるのを手伝ってください???