Topic
  • 1 reply
  • Latest Post - ‏2012-04-03T00:07:15Z by KamronK.
Enconthor
Enconthor
1 Post

Pinned topic actionListener problem

‏2011-03-18T16:59:50Z |
Hello all,
I have a problem with the actionListener method. Here is the code:
private class callhandler implements ActionListener{
public void actionPerformed(ActionEvent event){
if(event.getSource().equals(savecUser)){
String username = txtuserName.getText();
String password = txtpassword.getText();
String privilege = txtprivilege.getText();
if(username == "" || password == "" || privilege == ""){
JOptionPane.showMessageDialog(null, "Can't save empty user");
}else{
try {
admincontrol.EditUser(username, password, privilege);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
And my EditUser method:

public void EditUser(String username, String password, String privilege) throws Exception{
DeleteUser(username, password, privilege);
AddUser(username, password, privilege);
}

The problem?
When I try save user with blank fields for username, pasword, or privilege, it's not doing anything. It should open up dialog box as warning to user.

And when it's not blank, I am having to click the button twice for the button to actually do something. First click, delete's the user from database, and second one adds the user to database. it should just do it together.

Thanks for help.
Updated on 2012-04-03T00:07:15Z at 2012-04-03T00:07:15Z by KamronK.
  • KamronK.
    KamronK.
    3 Posts

    Re: actionListener problem

    ‏2012-04-03T00:07:15Z  
    How are you testing whether or not it is doing anything? or How do you confirm the codes outcome?