change pseudo avec l'interface

This commit is contained in:
Theau Giraud 2020-12-16 09:28:01 +01:00
parent 0c7fe930df
commit 9b230d6e26

View file

@ -170,7 +170,6 @@ public class Controller {
//sc1.close(); //sc1.close();
JOptionPane.showMessageDialog(null ,"Your nickname : " + tmpPseudo + " is valid !"); JOptionPane.showMessageDialog(null ,"Your nickname : " + tmpPseudo + " is valid !");
//hisView.Pseudolabel.setText("Your current username is: " + tmpPseudo);
return tmpPseudo; return tmpPseudo;
} }
@ -182,21 +181,22 @@ public class Controller {
* On regarde si le pseudo est bien différent de l'ancien * On regarde si le pseudo est bien différent de l'ancien
* </p> * </p>
*/ */
private void changePseudo() throws IOException { public void changePseudo() throws IOException {
String oldPseudo = this.myUser.getPseudo(); //Saves the old one for comparison String oldPseudo = this.myUser.getPseudo(); //Saves the old one for comparison
String tmpPseudo = JOptionPane.showInputDialog(null, "Enter nickname:"); // Read user input String tmpPseudo = hisView.PseudotextField.getText(); // Read user input
while(!(this.validatePseudo(tmpPseudo)) || tmpPseudo.equals(oldPseudo)) { while(!(this.validatePseudo(tmpPseudo)) || tmpPseudo.equals(oldPseudo)) {
tmpPseudo = JOptionPane.showInputDialog(null, "Already exist, enter another nickname :"); // Read user input hisView.Pseudolabel.setText("Already exists, enter another nickname. Your current username is: " + oldPseudo); // Read user input
} tmpPseudo = hisView.PseudotextField.getText(); // Read user input
}
this.myUser.setPseudo(tmpPseudo); this.myUser.setPseudo(tmpPseudo);
JOptionPane.showMessageDialog(null ,"Your new nickname : " + tmpPseudo + " is valid !"); JOptionPane.showMessageDialog(null ,"Your new nickname : " + tmpPseudo + " is valid !");
this.notify_remote_users(); this.notify_remote_users();
} }
/** /**
* <p> * <p>