Salut , je suis nouveau et un débutant en programmation java et j'ai besoin de votre aide.

Mon but, c'est de pouvoir mettre en réseau une application permettant de dessiner de façon à ce que lorsque l'on dessine du côté serveur, la fenêtre du client se met automatiquement à jour. Et le problème que j'ai rencontré, c'est que la fenêtre du client ne veut pas se mettre à jour sans que l'on ne clique dessus, cela doit être provoquée à cause de mon code qui se trouve à l'intérieur du mouseListener() dans la classe Panneau. Alors j'aimerai trouver un moyen pour que la mise à jour se fasse de façon automatique. Je vous remercie d'avance.

voici ma classe Panneau:

Code java : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
import java.awt.AWTException;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Robot;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
 
import javax.swing.JPanel;
 
 
public class Panneau extends JPanel{
 
 
	ArrayList<Point> listePoint= new ArrayList();
	int taillePointeur=50;
	String formePointeur="CARRE";
	Color couleurPointeur=Color.red;
	private Boolean clean=false,isHost=false,isConnected=false;
	private ServerSocket serverSocket;
	private Socket socket;
	ObjectOutputStream oos;
	ObjectInputStream ois;
	InputStream is;
	OutputStream os;
 
	public Point pointEnvoyer=new Point();
 
 
	public int getTaillePointeur() {
		return taillePointeur;
	}
 
 
	public void setTaillePointeur(int taillePointeur) {
		this.taillePointeur = taillePointeur;
	}
 
 
	public String getFormePointeur() {
		return formePointeur;
	}
 
 
	public void setFormePointeur(String formePointeur) {
		this.formePointeur = formePointeur;
	}
 
 
	public Color getCouleurPointeur() {
		return couleurPointeur;
	}
 
 
	public void setCouleurPointeur(Color couleurPointeur) {
		this.couleurPointeur = couleurPointeur;
	}
 
 
	public Boolean getClean() {
		return clean;
	}
 
 
	public void setClean(Boolean clean) {
		this.clean = clean;
	}
 
	public ArrayList<Point> getListePoint() {
		return listePoint;
	}
 
 
	public void setListePoint(ArrayList<Point> listePoint) {
		this.listePoint = listePoint;
	}
 
 
	public void drawPanel(){
 
		//essai
 
		if(isConnected){
 
			try {
				is=socket.getInputStream();
				os=socket.getOutputStream();
				oos=new ObjectOutputStream(os);
				ois=new ObjectInputStream(is);
 
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			if(!isHost){
 
				try {
					Point point = (Point)ois.readObject();
					listePoint.add(point);
				} catch (ClassNotFoundException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				} catch (IOException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		}
 
		this.addMouseListener(new MouseListener(){
 
			@Override
			public void mouseClicked(MouseEvent e) {
				// TODO Auto-generated method stub
				Point p=new Point(e.getX(),e.getY(),taillePointeur,formePointeur,couleurPointeur);
				setPointEnvoyer(p);
				//listePoint.add(new Point(e.getX(),e.getY(),taillePointeur,formePointeur,couleurPointeur));
 
				if(isConnected){
				try {
					if(isHost){
						oos.flush();
						listePoint.add(p);
						oos.writeObject(p);
					}
					else{
 
						try {
							Point point=(Point)ois.readObject();
							listePoint.add(point);
 
						} catch (ClassNotFoundException e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						}
					}
				} catch (IOException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
			}
 
			@Override
			public void mouseEntered(MouseEvent arg0) {
				// TODO Auto-generated method stub
 
			}
 
			@Override
			public void mouseExited(MouseEvent arg0) {
				// TODO Auto-generated method stub
 
			}
 
			@Override
			public void mousePressed(MouseEvent arg0) {
				// TODO Auto-generated method stub
 
			}
 
			@Override
			public void mouseReleased(MouseEvent arg0) {
				// TODO Auto-generated method stub
 
			}
 
		});
 
 
		this.addMouseMotionListener(new MouseMotionListener(){
 
			@Override
			public void mouseDragged(MouseEvent e) {
				// TODO Auto-generated method stub
				Point p=new Point(e.getX(),e.getY(),taillePointeur,formePointeur,couleurPointeur);
				setPointEnvoyer(p);
			//	listePoint.add(new Point(e.getX(),e.getY(),taillePointeur,formePointeur,couleurPointeur));
 
				if(isConnected){
				try {
					if(isHost){
						oos.flush();
						listePoint.add(p);
						System.out.println(oos.toString());
						oos.writeObject(p);
					}
					else{
						try {
							Point point=(Point)ois.readObject();
							listePoint.add(point);
 
						} catch (ClassNotFoundException e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						}
					}
				} catch (IOException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
			}
 
			@Override
			public void mouseMoved(MouseEvent arg0) {
				// TODO Auto-generated method stub
 
			}
 
		});
	}
 
 
	public void paintComponent(Graphics g){
 
		g.setColor(Color.white);
		g.fillRect(0, 0, this.getWidth(), this.getHeight());
 
		if(clean==true){
 
			this.clean=false;
			this.listePoint=new ArrayList<Point>();
			repaint();
		}
 
		else{
		for(Point p : this.listePoint){
			g.setColor(p.getCouleurPoint());
 
			if(p.getFormePoint().equals("CARRE")){
				g.fillRect(p.getX(), p.getY(), p.getTaillePoint(),p.getTaillePoint());
			}
			else{
				g.fillOval(p.getX(), p.getY(), p.getTaillePoint(), p.getTaillePoint());
			}
		}
 
		this.repaint();
		}
 
	}
 
 
	public void setServerSocket(ServerSocket serverSocket) {
		this.serverSocket = serverSocket;
	}
 
 
	public void setSocket(Socket socket) {
		this.socket = socket;
	}
 
 
	public void setIsHost(Boolean isHost) {
		this.isHost = isHost;
	}
 
 
	public void setIsConnected(Boolean isConnected) {
		this.isConnected = isConnected;
	}
 
 
	public Point getPointEnvoyer() {
		return pointEnvoyer;
	}
 
 
	public void setPointEnvoyer(Point pointEnvoyer) {
		this.pointEnvoyer = pointEnvoyer;
	}
 
 
 
}


et ma classe Fenetre:

Code java : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
 
import java.awt.AWTException;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Robot;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.ArrayList;
 
import javax.swing.AbstractButton;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JToolBar;
import javax.swing.KeyStroke;
 
 
 
public class Fenetre extends JFrame implements Runnable {
 
	private JMenuBar menu = new JMenuBar();
	private JToolBar toolBar= new JToolBar();
 
	private Panneau pan= new Panneau();
	private JPanel container = new JPanel();
 
	private JButton carreForme= new JButton(new ImageIcon("Images/square.jpg"));
	private JButton rondForme= new JButton(new ImageIcon("Images/circle.jpg"));
	private JButton rougeCarre=new JButton(new ImageIcon("Images/rouge.jpg"));
	private JButton vertCarre=new JButton(new ImageIcon("Images/vert.jpg"));
	private JButton bleuCarre=new JButton(new ImageIcon("Images/bleu.jpg"));
 
	private JMenu fichier = new JMenu("Fichier");
	private JMenu edition = new JMenu("Edition");
	private JMenu formeDuPointeur=new JMenu("Forme du pointeur");
	private JMenu couleurDuPointeur=new JMenu("Couleur du pointeur");
 
	private JMenuItem enregistrer= new JMenuItem("Enregistrer");
	private JMenuItem enregistrerSous = new JMenuItem("Enregistrer sous");
	private JMenuItem ouvrir= new JMenuItem("Ouvrir");
	private JMenuItem effacer= new JMenuItem("Effacer");
	private JMenuItem quitter= new JMenuItem("Quitter");
	private JMenuItem rond= new JMenuItem("Rond");
	private JMenuItem carre= new JMenuItem("Carre");
	private JMenuItem rouge = new JMenuItem("Rouge");
	private JMenuItem vert = new JMenuItem("Vert");
	private JMenuItem bleu= new JMenuItem("Bleu");
 
	JFileChooser fileChooser= new JFileChooser("Sauvegarde/");
	ZFileFilter zFiltre = new ZFileFilter();
	ZFileFilter filtre= new ZFileFilter(".amz","Fichier Ardoise Magique");
	File file ; 
 
	private Point point1 = new Point();
 
	//essai fen
	private ButtonGroup bg=new ButtonGroup();
	private JRadioButton hostBouton=new JRadioButton("Host");
	private JRadioButton guestBouton=new JRadioButton("Guest");
	private JButton connexion=new JButton("Connexion"),deconnexion=new JButton("Deconnexion");
	private Boolean isHost=true;
	private JLabel status=new JLabel("Déconnecté");
 
	public static ServerSocket hostServer = null;
	public static Socket socket = null;
 
 
 
 
	private formeListener fListener= new formeListener();
	private couleurListener cListener= new couleurListener();
 
	public Fenetre(){
		this.setTitle("Ardoise Magique");
		this.setSize(800, 600);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setLocationRelativeTo(null);
 
		this.fileChooser.addChoosableFileFilter(zFiltre);
		this.fileChooser.addChoosableFileFilter(filtre);
 
 
		container.setLayout(new BorderLayout());
		// interface mouseListener
 
		//Ajout du menu
		this.initMenu();
 
 
		pan.drawPanel();
		container.add(pan);
 
		this.setContentPane(container);
 
 
 
		// ajout de la barre d'outils
		this.initToolBar();
 
		this.setVisible(true);
 
 
	}
 
	// initialisation de la barre d'outils
	private void initToolBar(){
 
		carreForme.addActionListener(fListener);
		this.toolBar.add(carreForme);
 
		rondForme.addActionListener(fListener);
		this.toolBar.add(rondForme);
 
		this.toolBar.addSeparator();
 
		rougeCarre.addActionListener(cListener);
		this.toolBar.add(rougeCarre);
 
		bleuCarre.addActionListener(cListener);
		this.toolBar.add(bleuCarre);
 
		vertCarre.addActionListener(cListener);
		this.toolBar.add(vertCarre);
 
		//gestion de la connexion
 
 
		hostBouton.setSelected(true);
 
		if(hostBouton.isSelected()){
			setIshost(true);
			status.setText("En attente de connexion");
		}
		else{
			setIshost(false);
		}
 
		bg.add(hostBouton);
		bg.add(guestBouton);
 
		this.toolBar.add(hostBouton,BorderLayout.EAST);
		this.toolBar.add(guestBouton);
 
		//gestion de la connexion
		connexion.addActionListener(new ActionListener() {
 
			@Override
			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
 
				if(hostBouton.isSelected()){
 
					try {
						hostServer=new ServerSocket(1234);
						socket=hostServer.accept();
						pan.setIsHost(true);
						status.setText("connecté");
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
 
				}
				else{
					try {
						status.setText("en train de se connecter");
						socket=new Socket("localhost",1234);
						pan.setIsHost(false);
						status.setText("connecté");
					} catch (UnknownHostException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
 
				pan.setIsConnected(true);
				pan.setServerSocket(hostServer);
				pan.setSocket(socket);
				pan.drawPanel();
 
			}
		});
 
		deconnexion.addActionListener(new ActionListener() {
 
			@Override
			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
				if(hostBouton.isSelected()){
					try {
						hostServer.close();
						socket.close();
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
 
				}
				else{
					try {
						socket.close();
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
				status.setText("déconnecté");
			}
		});
 
		this.toolBar.add(connexion);
		this.toolBar.add(deconnexion);
 
		//ajout du label pour le statut de la connexion 
		this.toolBar.add(status);
 
		this.add(toolBar,BorderLayout.NORTH);
	}
 
	private void initMenu(){
 
		enregistrer.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,KeyEvent.CTRL_DOWN_MASK));
		enregistrer.addActionListener(new ActionListener(){
 
			@Override
			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
 
				ObjectOutputStream oos;
 
				if(file!=null){
				try{
 
					oos=new ObjectOutputStream(new FileOutputStream(file));
					oos.writeObject(pan.getListePoint());
					oos.close();
 
				}catch(FileNotFoundException e){
					e.printStackTrace();
				}catch(IOException e){
					e.printStackTrace();
				}
				}
 
				else{
					if(fileChooser.showSaveDialog(null)==JFileChooser.APPROVE_OPTION){
						file=fileChooser.getSelectedFile();
					}
 
					if(fileChooser.getFileFilter().accept(file)){
						try {
							oos=new ObjectOutputStream(new FileOutputStream(file));
							oos.writeObject(pan.getListePoint());
							oos.close();
						} catch (FileNotFoundException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}catch(IOException e){
							e.printStackTrace();
						}
					}
					else{
						JOptionPane alert= new JOptionPane();
						alert.showMessageDialog(null,"Erreur d'extension de fichier\nVotre sauvegarde a échoué !","Erreur",JOptionPane.ERROR_MESSAGE);
					}
				}
			}
 
		});
 
		fichier.add(enregistrer);
 
		enregistrerSous.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK));
		enregistrerSous.addActionListener(new ActionListener(){
 
			@Override
			public void actionPerformed(ActionEvent arg0) {
 
				ObjectOutputStream oos;
 
				// TODO Auto-generated method stub
				if(fileChooser.showSaveDialog(null)==JFileChooser.APPROVE_OPTION){
					file=fileChooser.getSelectedFile();
					if(fileChooser.getFileFilter().accept(file)){
						try{
							oos=new ObjectOutputStream(new FileOutputStream(file));
							oos.writeObject(pan.getListePoint());
							oos.close();
						}catch(FileNotFoundException e){
							e.printStackTrace();
						}catch(IOException e){
							e.printStackTrace();
						}
					}
 
					else{
						JOptionPane alert = new JOptionPane();
						alert.showMessageDialog(null, "Erreur d'extension de fichier \n Votre sauvegarde a échoué","Erreur",JOptionPane.ERROR_MESSAGE);
					}
				}
			}
 
		});
 
		fichier.add(enregistrerSous);
 
		ouvrir.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,KeyEvent.CTRL_DOWN_MASK));
		ouvrir.addActionListener(new ActionListener(){
 
			@Override
			public void actionPerformed(ActionEvent arg0) {
 
				ObjectInputStream ois;
 
				// TODO Auto-generated method stub
				if(fileChooser.showOpenDialog(null)==JFileChooser.APPROVE_OPTION)
					file=fileChooser.getSelectedFile();
 
				if(fileChooser.getFileFilter().accept(file)){
					try {
						ois=new ObjectInputStream(new FileInputStream(file));
						pan.setListePoint((ArrayList<Point>)ois.readObject());
						ois.close();
					} catch (FileNotFoundException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					} catch (IOException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					} catch (ClassNotFoundException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
 
				else{
					JOptionPane alert = new JOptionPane();
					alert.showMessageDialog(null, "Erreur d'extension de fichier\nL'ouverture a échoué","Erreur",JOptionPane.ERROR_MESSAGE);
				}
			}
 
		});
 
		fichier.add(ouvrir);
 
		fichier.addSeparator();
 
		// ajout des mnemonics
		fichier.setMnemonic('F');
		this.menu.add(fichier);
 
		edition.setMnemonic('E');
		this.menu.add(edition);
 
		// ajout des accélérateurs // à réctifierrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
		effacer.addActionListener(new ActionListener(){
 
			@Override
			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
				pan.setClean(true);
			}
 
		});
		effacer.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,KeyEvent.CTRL_DOWN_MASK));
		fichier.add(effacer);
 
		quitter.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W,KeyEvent.CTRL_DOWN_MASK));
		quitter.addActionListener(new ActionListener(){
 
			@Override
			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
				System.exit(0);
			}
 
		});
		fichier.add(quitter);
 
		edition.add(formeDuPointeur);
		edition.add(couleurDuPointeur);
 
 
		//ajout des listener
		rond.addActionListener(fListener);
		formeDuPointeur.add(rond);
 
		carre.addActionListener(fListener);
		formeDuPointeur.add(carre);
 
		rouge.addActionListener(cListener);
		couleurDuPointeur.add(rouge);
 
		vert.addActionListener(cListener);
		couleurDuPointeur.add(vert);
 
		bleu.addActionListener(cListener);
		couleurDuPointeur.add(bleu);
 
		this.setJMenuBar(menu);
	}
 
	class formeListener implements ActionListener{
 
		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			if(e.getSource()==carre){
				pan.setFormePointeur("CARRE");
			}
			else if(e.getSource()==rond)
			{
				pan.setFormePointeur("ROND");
			}
			else{
				if(e.getSource()==carreForme){
					carre.doClick();
				}
 
				else{
					rond.doClick();
				}
			}
		}
 
	}
 
	class couleurListener implements ActionListener{
 
		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			if(((AbstractButton) e.getSource()).getText()=="Rouge"){
				pan.setCouleurPointeur(Color.red);
			}
 
			else if(((AbstractButton) e.getSource()).getText()=="Vert"){
				pan.setCouleurPointeur(Color.green);
			}
 
			else if(((AbstractButton) e.getSource()).getText()=="Bleu"){
				pan.setCouleurPointeur(Color.blue);
			}
 
			else{
				if(e.getSource()==rougeCarre){
					rouge.doClick();
				}
 
				else if(e.getSource()==vertCarre){
					vert.doClick();
				}
 
				else{
					bleu.doClick();
				}
			}
			}
 
	}
 
	public void setIshost(Boolean ishost) {
		this.isHost = ishost;
	}
 
	@Override
	public void run() {
		// TODO Auto-generated method stub
		try {
			if(isHost){
				hostServer=new ServerSocket(2345);
				status.setText("En attente d'une connexion");
				socket=hostServer.accept();
				status.setText("Connexion établie");
				hostServer.close();
			}
			else{
				socket=new Socket("localhost",2345);
				status.setText("Connecté");
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
 
 
}


et ma classe Point:

Code java : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
 
import java.awt.Color;
import java.io.Serializable;
 
 
public class Point implements Serializable {
 
	private int taillePoint,x,y;
	private String formePoint;
	private Color couleurPoint;
 
	Point(){
 
	}
 
	Point(int x,int y,int taille, String forme, Color couleur){
		this.x=x;
		this.y=y;
		this.taillePoint=taille;
		this.formePoint=forme;
		this.couleurPoint=couleur;
	}
 
	public int getX() {
		return x;
	}
 
	public void setX(int x) {
		this.x = x;
	}
 
	public int getY() {
		return y;
	}
 
	public void setY(int y) {
		this.y = y;
	}
 
	public int getTaillePoint() {
		return taillePoint;
	}
 
	public void setTaillePoint(int taillePoint) {
		this.taillePoint = taillePoint;
	}
 
	public String getFormePoint() {
		return formePoint;
	}
 
	public void setFormePoint(String formePoint) {
		this.formePoint = formePoint;
	}
 
	public Color getCouleurPoint() {
		return couleurPoint;
	}
 
	public void setCouleurPoint(Color couleurPoint) {
		this.couleurPoint = couleurPoint;
	}
 
 
}