java - What is wrong with my JTextField here? (details in text) -


edit: ui class sends #login client, client sends server, server sends "@login" client indicating successful log-in , client sends "@login" along ui via ui.display()

apologies bad grammar/formatting.

here's relevant block of code, explanation follow:

    else if (e.getsource() == this.loginbutton)     {                        if (this.soundon == true)         {             this.clicksound.play();         }             this.client.handlemessagefromclientui("#login "+this.loginfield.gettext());         this.client.handlemessagefromclientui("#balance");         this.client.setloginid(this.loginfield.gettext());                                if (this.loggedin)         {             this.loginbutton.setenabled(true);              this.note.settext("account screen");             this.status.settext("logged in to: "+this.client.getloginid());                           this.maindisplay.removeall();                        this.controlbar.removeall();              this.maindisplay.add(box.createrigidarea(new dimension(0,30)));             this.maindisplay.add(this.title);                                            this.maindisplay.add(box.createrigidarea(new dimension(0,50)));             this.maindisplay.add(box.createrigidarea(new dimension(100,0)));             this.maindisplay.add(this.balancelabel);                                                                       this.maindisplay.add(box.createrigidarea(new dimension(0,110)));              this.controlbar.add(debitbutton);             this.controlbar.add(creditbutton);             this.controlbar.add(quitbutton);              this.repaint();                          }         else         {             joptionpane.showmessagedialog(null, "log-in failed.", "alert", joptionpane.error_message);         }     }    public void display(string msg) {            if (msg.startswith("@login"))     {         this.loggedin = true;     }     else if (msg.startswith("@balance"))     {         this.balancelabel.settext("balance: $"+msg.substring(43));         this.repaint();     }     else if (msg.startswith("@alert"))     {         joptionpane.showmessagedialog(null, msg.substring(7), "server message", joptionpane.plain_message);     }     else     {         //joptionpane.showmessagedialog(null, msg, "server message", joptionpane.information_message); //for debugging     } } 

this part of class, here's rest: http://pastebin.com/3f99efwk

my problem in actionperformed(actionevent e) in loginbutton case. goes block once when button clicked:

        else         {             joptionpane.showmessagedialog(null, "log-in failed.", "alert", joptionpane.error_message);         } 

then if click button again works , goes if (this.loggedin) case block. loggedin=true obtained when line executed:

this.client.handlemessagefromclientui("#login "+this.loginfield.gettext()); 

which in turn calls:

public void handlemessagefromclientui(string message) { else   {        try       {           sendtoserver(message);       }       catch(ioexception e)       {           clientui.display("could not send message server.");           //quit();       }   } } 

which calls server.handlemessagefromclient(object msg, connection client) has following relevant code in it:

                try                 {                     client.sendtoclient("@login logging in account: "+tempstr);                                           }                 catch (ioexception e)                 {                      system.out.println("failed send message client");                 }                 client.setinfo("loginid", tempstr); 

i know doesn't fail send, i've tested out. problem why if statement in actionperformed fail first time button pressed though text typed in textfield, passes second time??


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -