diff --git a/Application/Clavardage/src/controller/Controller.java b/Application/Clavardage/src/controller/Controller.java index 2488cae..77e4a46 100644 --- a/Application/Clavardage/src/controller/Controller.java +++ b/Application/Clavardage/src/controller/Controller.java @@ -70,11 +70,7 @@ public class Controller { notify_remote_users(); - javax.swing.SwingUtilities.invokeLater(new Runnable() { - public void run() { - hisView.createAndShowGUI(); - } - }); + } /** @@ -432,7 +428,9 @@ public class Controller { Controller ctr3 = new Controller(12224,portUDPlistening_remoteUsr3,22223,"Alice"); Controller ctr1 = new Controller(12225,20001,22221); // Notre utilisateur local - + // Création de l'interface + ctr1.hisView=Interface.createAndShowGUI(ctr1); + // Fonction appelé par notre utilisateur local ctr1.getOneActiveUser(); ctr1.changePseudo(); diff --git a/Application/Clavardage/src/view/Interface.java b/Application/Clavardage/src/view/Interface.java index 4b6ce58..efc6153 100644 --- a/Application/Clavardage/src/view/Interface.java +++ b/Application/Clavardage/src/view/Interface.java @@ -23,6 +23,10 @@ public class Interface implements ActionListener { //null (use the default), "Metal", "System", "Motif", "GTK+" final static String LOOKANDFEEL = "System"; + public Interface(Controller controller) { + this.controller = controller; + } + public Component createComponents() { PseudotextField = new JTextField(); //Pseudo setup PseudotextField.setColumns(10); @@ -128,7 +132,7 @@ public class Interface implements ActionListener { * this method should be invoked from the * event-dispatching thread. */ - public static void createAndShowGUI() { + public static Interface createAndShowGUI(Controller controller) { //Set the look and feel. initLookAndFeel(); @@ -139,15 +143,17 @@ public class Interface implements ActionListener { JFrame frame = new JFrame("SwingApplication"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - Interface app = new Interface(); + Interface app = new Interface(controller); Component contents = app.createComponents(); frame.getContentPane().add(contents, BorderLayout.CENTER); //Display the window. frame.pack(); frame.setVisible(true); - } + return app; + } + /* public static void main(String[] args) throws IOException { //Schedule a job for the event-dispatching thread: //creating and showing this application’s GUI. @@ -156,6 +162,6 @@ public class Interface implements ActionListener { createAndShowGUI(); } }); - } + }*/ }