Java simple login function not working
Hello there :)
i have this simple login function where i compare what you write with what is in the array and if it is the same it will open a new window else nothing will happen but it doesn't seem to work :/
can someone please help me what is wrong with my code?
Code :
login.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String[] usernameArray={"User1","User2","User3"}; //array where i save file username and a other one for password
String[] passwordArray={"Pass1","Pass2","Pass3"};
for (int i=0; i<usernameArray.length; i++){ // make a for loop so it tjeks all the different users
if((usernameField.equals(usernameArray[i]) && passwordField.equals(passwordArray[i]))){
JOptionPane.showMessageDialog(null,"Welcome "+usernameField+"\n"+"You are logged in");
login.addActionListener(new login());
dialog.setVisible(false);
frame.setVisible(false);
}
} // end of for loop
}
});
Re: Java simple login function not working
Argument size was increased in Message Dialogue Box
Re: Java simple login function not working
Quote:
Originally Posted by
vigneshwaran
Argument size was increased in Message Dialogue Box
and what does that mean?
Re: Java simple login function not working
Quote:
Originally Posted by
vigneshwaran
Argument size was increased in Message Dialogue Box
Mind telling me how?
@vigneshwaran: You need to read about what addActionListener does. You are no where calling the new GUI to display.
Re: Java simple login function not working
don't i do that with
Code :
login.addActionListener(new login());
or is that just me that is wrong? because i can make it work if i take it out of the login method there then it works butn when i put it in the login method it doesn't wanna open the new window or anything :/
Re: Java simple login function not working
Quote:
Originally Posted by
lf2killer
don't i do that with
Code :
login.addActionListener(new login());
or is that just me that is wrong? because i can make it work if i take it out of the login method there then it works butn when i put it in the login method it doesn't wanna open the new window or anything :/
Yeah please read about what addActionListener does. You will get your answer.