【发布时间】:2014-09-15 21:57:54
【问题描述】:
动作监听器代码
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");
}
}
});
播放器类代码
public boolean login(String username){
if(username == "adam"){
return true;
} else {
return false;
}
}
无论输入什么,我总是提示用户名错误,我该怎么办?我做错了什么?
【问题讨论】:
标签: java swing oop actionlistener