From 9b230d6e26ed777acedd4a6d184293e47bd13edd Mon Sep 17 00:00:00 2001
From: tgiraud
Date: Wed, 16 Dec 2020 09:28:01 +0100
Subject: [PATCH] change pseudo avec l'interface
---
.../Clavardage/src/controller/Controller.java | 22 +++++++++----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/Application/Clavardage/src/controller/Controller.java b/Application/Clavardage/src/controller/Controller.java
index c07fa23..e715511 100644
--- a/Application/Clavardage/src/controller/Controller.java
+++ b/Application/Clavardage/src/controller/Controller.java
@@ -170,7 +170,6 @@ public class Controller {
//sc1.close();
JOptionPane.showMessageDialog(null ,"Your nickname : " + tmpPseudo + " is valid !");
- //hisView.Pseudolabel.setText("Your current username is: " + tmpPseudo);
return tmpPseudo;
}
@@ -182,21 +181,22 @@ public class Controller {
* On regarde si le pseudo est bien différent de l'ancien
*
*/
- private void changePseudo() throws IOException {
- String oldPseudo = this.myUser.getPseudo(); //Saves the old one for comparison
+ public void changePseudo() throws IOException {
+ 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)) {
- tmpPseudo = JOptionPane.showInputDialog(null, "Already exist, enter another nickname :"); // Read user input
- }
+ while(!(this.validatePseudo(tmpPseudo)) || tmpPseudo.equals(oldPseudo)) {
+ 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();
+ }
/**
*