Browse Source

lien controller-view

Alexandre Gonzalvez 3 years ago
parent
commit
27d44abacf

+ 4
- 6
Application/Clavardage/src/controller/Controller.java View File

@@ -70,11 +70,7 @@ public class Controller {
70 70
 		
71 71
 		notify_remote_users();
72 72
 		
73
-		javax.swing.SwingUtilities.invokeLater(new Runnable() {
74
-			public void run() {
75
-				hisView.createAndShowGUI();
76
-			}
77
-		});
73
+		
78 74
 	}
79 75
 	
80 76
 	/**
@@ -432,7 +428,9 @@ public class Controller {
432 428
 			Controller ctr3 = new Controller(12224,portUDPlistening_remoteUsr3,22223,"Alice"); 
433 429
 			Controller ctr1 = new Controller(12225,20001,22221); // Notre utilisateur local
434 430
 
435
-			
431
+			// Création de l'interface
432
+			ctr1.hisView=Interface.createAndShowGUI(ctr1);	
433
+						
436 434
 			// Fonction appelé par notre utilisateur local
437 435
 			ctr1.getOneActiveUser();
438 436
 			ctr1.changePseudo();

+ 10
- 4
Application/Clavardage/src/view/Interface.java View File

@@ -23,6 +23,10 @@ public class Interface implements ActionListener {
23 23
 	//null (use the default), "Metal", "System", "Motif", "GTK+"
24 24
 	final static String LOOKANDFEEL = "System";
25 25
 	
26
+	public Interface(Controller controller) {
27
+		this.controller = controller;
28
+	}
29
+	
26 30
 	public Component createComponents() {
27 31
 		PseudotextField = new JTextField();        //Pseudo setup
28 32
 		PseudotextField.setColumns(10);
@@ -128,7 +132,7 @@ public class Interface implements ActionListener {
128 132
 	* this method should be invoked from the
129 133
 	* event-dispatching thread.
130 134
 	*/
131
-	public static void createAndShowGUI() {
135
+	public static Interface createAndShowGUI(Controller controller) {
132 136
 		//Set the look and feel.
133 137
 		initLookAndFeel();
134 138
 		
@@ -139,15 +143,17 @@ public class Interface implements ActionListener {
139 143
 		JFrame frame = new JFrame("SwingApplication");
140 144
 		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
141 145
 		
142
-		Interface app = new Interface();
146
+		Interface app = new Interface(controller);
143 147
 		Component contents = app.createComponents();
144 148
 		frame.getContentPane().add(contents, BorderLayout.CENTER);
145 149
 			
146 150
 		//Display the window.
147 151
 		frame.pack();
148 152
 		frame.setVisible(true);
149
-	}
150 153
 		
154
+		return app;
155
+	}
156
+		/*
151 157
 	public static void main(String[] args) throws IOException {
152 158
 		//Schedule a job for the event-dispatching thread:
153 159
 		//creating and showing this application’s GUI.
@@ -156,6 +162,6 @@ public class Interface implements ActionListener {
156 162
 				createAndShowGUI();
157 163
 			}
158 164
 		});
159
-	}
165
+	}*/
160 166
 }
161 167
 

Loading…
Cancel
Save