Actionlistener code
Player p = new Player();
/**
** Other code here
**/
private static JLabel Status;
final JTextField username = new JTextField(6);
loginButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
data = username.getText();
if(p.Login(data)){
Status.setText(data+" is correct");
} else {
Status.setText(data+" is wrong");
}
}
});
Player class code
public boolean login(String username){
if(username == "adam"){
return true;
} else {
return false;
}
}
I am always getting that username is wrong no matter what input there is, what should I do? what am I doing wrong?