-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathInterface.java
562 lines (528 loc) · 20.2 KB
/
Interface.java
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
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.Object;
/* -------ATTENTION---------*/
/* Si les pieces ne s'affichent pas, il faut indiquer le chemin de votre dossier img dans le constructeur */
public class Interface extends JFrame {
private JFrame fenetre;
private JFrame promotion;
private JPanel poschrono;
private JPanel plateau[][];
private JPanel cimetiereBlanc[][];
private JPanel cimetiereNoir[][];
private JPanel posPlateau;
private JPanel posCimetiereBlanc;
private JPanel posCimetiereNoir;
private JPanel tour;
private JPanel fou;
private JPanel cavalier;
private JPanel reine;
private JLabel lettre[];
private JLabel chiffre[];
private JMenuBar menu;
private JMenu menu1;
private JMenu menu2;
private JMenu menu3;
private JMenu menu4;
private JMenu joueur;
private int is;
private int js;
private int clicX;
private int clicY;
private boolean newPartie;
private String cheminImg;
private String formePromo;
private DTimer time;
public Interface(){
cheminImg="/img/"; //chemin du dossier img
fenetre = new JFrame();
poschrono=new JPanel();
plateau = new JPanel[9][9];
cimetiereBlanc=new JPanel[2][8];
cimetiereNoir=new JPanel[2][8];
lettre = new JLabel [8];
chiffre = new JLabel [8];
newPartie=false;
// CONFIG DE LA FENETRE //
fenetre.setTitle("Jeu d'échec");
fenetre.setSize(800,620); // taille en pixel de la largeur et hauteur de la fenetre
fenetre.setLayout(new BorderLayout());
fenetre.setLocationRelativeTo(null);
fenetre.setResizable(false); // empeche le redimenssionnement de la fenetre
fenetre.setVisible(true);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// MENU //
menu = new JMenuBar();
menu1=new JMenu("Nouvelle partie");
menu1.addMouseListener(new MouseAdapter(){;
public void mouseClicked(MouseEvent e) {
newPartie=true;
}
});
menu.add(menu1); // On ajoute nouvelle partie au menu
menu2=new JMenu("Abandonner");
menu2.addMouseListener(new MouseAdapter(){;
public void mouseClicked(MouseEvent e) {
JOptionPane.showMessageDialog(null, "Un joueur a abandonné la partie!", "ABANDON", JOptionPane.INFORMATION_MESSAGE);
newPartie=true;
}
});
menu.add(menu2); // On ajoute abandonner au menu
menu3=new JMenu("Quitter");
menu3.addMouseListener(new MouseAdapter(){;
public void mouseClicked(MouseEvent e) {
System.exit(0);
}
});
menu.add(menu3); // On ajoute quitter au menu
menu4=new JMenu("Aide");
menu4.addMouseListener(new MouseAdapter(){;
public void mouseClicked(MouseEvent e) {
Aide a=new Aide();
a.regle();
a.pion();
a.tour();
a.fou();
a.cavalier();
a.roi();
a.reine();
}
});
menu.add(menu4);
joueur=new JMenu();
menu.add(joueur); // On ajoute la couleur du joueur qui doit jouer
fenetre.setJMenuBar(menu); // On ajoute le menu à la fenetre
// CONFIG DU CHRONO //
poschrono.setLayout(new BorderLayout());
time=new DTimer();
poschrono.add(time.getViewTime(),BorderLayout.CENTER);
fenetre.add(poschrono,BorderLayout.NORTH);
}
public DTimer getTimer(){
return time;
}
public boolean newPart(){
return newPartie;
}
public void setPart(){
newPartie=false;
}
public void remplirLettre(){
lettre[0]=new JLabel("A");
lettre[1]=new JLabel("B");
lettre[2]=new JLabel("C");
lettre[3]=new JLabel("D");
lettre[4]=new JLabel("E");
lettre[5]=new JLabel("F");
lettre[6]=new JLabel("G");
lettre[7]=new JLabel("H");
for(int i=0;i<8;i++) lettre[i].setForeground(Color.white);
}
public void remplirChiffre(){
chiffre[0]=new JLabel(" 8");
chiffre[1]=new JLabel(" 7");
chiffre[2]=new JLabel(" 6");
chiffre[3]=new JLabel(" 5");
chiffre[4]=new JLabel(" 4");
chiffre[5]=new JLabel(" 3");
chiffre[6]=new JLabel(" 2");
chiffre[7]=new JLabel(" 1");
for(int i=0;i<8;i++) chiffre[i].setForeground(Color.white);
}
public void afficherPlateau(){
for(int i=0;i<8;i++){
for(int j=0;j<8;j++){
if((i%2==0 && j%2==1) || (i%2==1 && j%2==0)){
plateau[i][j] = new JPanel(new BorderLayout());
plateau[i][j].setBackground(new Color(122,76,42));
plateau[i][j].setBorder(BorderFactory.createLineBorder(Color.black));
plateau[i][j].setPreferredSize(new Dimension(60,60));
}
else {
plateau[i][j] = new JPanel();
plateau[i][j].setBackground(new Color(206,158,86));
plateau[i][j].setBorder(BorderFactory.createLineBorder(Color.black));
plateau[i][j].setPreferredSize(new Dimension(60, 60));
}
}
}
for (int j=0;j<8;j++){
plateau[8][j]=new JPanel(new BorderLayout());
plateau[8][j].setPreferredSize(new Dimension(30,60));
plateau[8][j].setBackground(new Color(69,34,14));
plateau[8][j].setBorder(BorderFactory.createLineBorder(Color.black));
plateau[8][j].add(chiffre[j],BorderLayout.CENTER);
}
for (int i=0;i<8;i++){
plateau[i][8]=new JPanel();
plateau[i][8].setPreferredSize(new Dimension(60,30));
plateau[i][8].setBackground(new Color(69,34,14));
plateau[i][8].setBorder(BorderFactory.createLineBorder(Color.black));
plateau[i][8].add(lettre[i]);
}
plateau[8][8]=new JPanel();
plateau[8][8].setPreferredSize(new Dimension(30,30));
plateau[8][8].setBackground(new Color(69,34,14));
plateau[8][8].setBorder(BorderFactory.createLineBorder(Color.black));
}
public void clicPlateau(){
for(int i=0;i<8;i++){
for(int j=0;j<8;j++){
is=i;
js=j;
plateau[i][j].addMouseListener(new MouseAdapter(){;
int x=getJs();
int y=getIs();
public void mouseClicked(MouseEvent e) {
clicX=x;
clicY=y;
}
});
}
}
}
public int getClicX(){ return clicX; }
public int getClicY(){ return clicY; }
public int getIs(){ return is; }
public int getJs(){ return js; }
public void afficherCimetiere(){
for(int i=0;i<2;i++){
for (int j=0;j<8;j++){
if((i%2==0 && j%2==1) || (i%2==1 && j%2==0)){
cimetiereBlanc[i][j] = new JPanel(new BorderLayout());
cimetiereBlanc[i][j].setBackground(new Color(122,76,42));
cimetiereBlanc[i][j].setBorder(BorderFactory.createLineBorder(Color.black));
cimetiereBlanc[i][j].setPreferredSize(new Dimension(60,60));
cimetiereNoir[i][j] = new JPanel(new BorderLayout());
cimetiereNoir[i][j].setBackground(new Color(122,76,42));
cimetiereNoir[i][j].setBorder(BorderFactory.createLineBorder(Color.black));
cimetiereNoir[i][j].setPreferredSize(new Dimension(60,60));
}
else{
cimetiereBlanc[i][j] = new JPanel(new BorderLayout());
cimetiereBlanc[i][j].setBackground(new Color(206,158,86));
cimetiereBlanc[i][j].setBorder(BorderFactory.createLineBorder(Color.black));
cimetiereBlanc[i][j].setPreferredSize(new Dimension(60,60));
cimetiereNoir[i][j] = new JPanel(new BorderLayout());
cimetiereNoir[i][j].setBackground(new Color(206,158,86));
cimetiereNoir[i][j].setBorder(BorderFactory.createLineBorder(Color.black));
cimetiereNoir[i][j].setPreferredSize(new Dimension(60,60));
}
}
}
}
public void positionnerCases(){
posPlateau = new JPanel();
posPlateau.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0; // case de depart
gbc.gridy = 0; // case de depart
gbc.gridheight = 1; // taille hauteur
gbc.gridwidth = 1; // taille largeur
for(int i=0;i<9;i++){
for(int j=0;j<9;j++){
gbc.gridx = i;
gbc.gridy = j;
posPlateau.add(plateau[i][j], gbc);
}
}
// posPlateau.setBackground(new Color(240,163,73)); // si on veut mettre un fond de couleur
fenetre.add(posPlateau,BorderLayout.CENTER);
}
public void positionnerCimetiere(){
posCimetiereBlanc=new JPanel();
posCimetiereNoir=new JPanel();
posCimetiereBlanc.setLayout(new GridBagLayout());
posCimetiereNoir.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0; // case de depart
gbc.gridy = 0; // case de depart
gbc.gridheight = 1; // taille hauteur
gbc.gridwidth = 1; // taille largeur
for(int i=0;i<2;i++){
for(int j=0;j<8;j++){
gbc.gridx = i;
gbc.gridy = j;
posCimetiereBlanc.add(cimetiereBlanc[i][j],gbc);
posCimetiereNoir.add(cimetiereNoir[i][j],gbc);
}
}
// posCimetiereBlanc.setBackground(new Color(240,163,73)); // si on veut mettre un fond de couleur
// posCimetiereNoir.setBackground(new Color(240,163,73));
fenetre.add(posCimetiereNoir,BorderLayout.WEST);
fenetre.add(posCimetiereBlanc,BorderLayout.EAST);
}
public void afficherPiecesCimetiere(Echiquier e){
for(int i=0;i<e.getNbMortsBlanc();i++) {/*-cimetiere blanc-*/
if(e.existePieceCimetiere("blanc" ,i)){
if(e.getPieceCimetiere("blanc" ,i).getForme()=="tour"){
ImageIcon icon = new ImageIcon(getClass().getResource("./img/tour_blanc.png"));
JLabel img = new JLabel(icon);
cimetiereBlanc[i%2][i/2].add(img);
}
if(e.getPieceCimetiere("blanc" ,i).getForme()=="cavalier"){
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"cavalier_blanc.png"));
JLabel img = new JLabel(icon);
cimetiereBlanc[i%2][i/2].add(img);
}
if(e.getPieceCimetiere("blanc" ,i).getForme()=="fou"){
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"fou_blanc.png"));
JLabel img = new JLabel(icon);
cimetiereBlanc[i%2][i/2].add(img);
}
if(e.getPieceCimetiere("blanc" ,i).getForme()=="pion"){
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"pion_blanc.png"));
JLabel img = new JLabel(icon);
cimetiereBlanc[i%2][i/2].add(img);
}
if(e.getPieceCimetiere("blanc" ,i).getForme()=="reine"){
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"reine_blanc.png"));
JLabel img = new JLabel(icon);
cimetiereBlanc[i%2][i/2].add(img);
}
if(e.getPieceCimetiere("blanc" ,i).getForme()=="roi"){
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"roi_blanc.png"));
JLabel img = new JLabel(icon);
cimetiereBlanc[i%2][i/2].add(img);
}
}
} /*-cimetiere noir -*/
for(int i=0;i<e.getNbMortsNoir();i++) {
if(e.existePieceCimetiere("noir" ,i)){
if(e.getPieceCimetiere("noir" ,i).getForme()=="tour"){
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"tour_noir.png"));
JLabel img = new JLabel(icon);
cimetiereNoir[i%2][i/2].add(img);
}
if(e.getPieceCimetiere("noir" ,i).getForme()=="cavalier"){
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"cavalier_noir.png"));
JLabel img = new JLabel(icon);
cimetiereNoir[i%2][i/2].add(img);
}
if(e.getPieceCimetiere("noir" ,i).getForme()=="fou"){
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"fou_noir.png"));
JLabel img = new JLabel(icon);
cimetiereNoir[i%2][i/2].add(img);
}
if(e.getPieceCimetiere("noir" ,i).getForme()=="pion"){
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"pion_noir.png"));
JLabel img = new JLabel(icon);
cimetiereNoir[i%2][i/2].add(img);
}
if(e.getPieceCimetiere("noir" ,i).getForme()=="reine"){
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"reine_noir.png"));
JLabel img = new JLabel(icon);
cimetiereNoir[i%2][i/2].add(img);
}
if(e.getPieceCimetiere("noir" ,i).getForme()=="roi"){
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"roi_noir.png"));
JLabel img = new JLabel(icon);
cimetiereNoir[i%2][i/2].add(img);
}
}
}
}
//permet d'afficher les pieces du tableau de pieces de la classe Echiquier
public void afficherPieces(Echiquier e){
for(int i=0;i<8;i++) {
for(int j=0; j<8;j++){
if(e.existePiece(i,j)){
if(e.getPiece(i,j).getCouleur()=="blanc"){
if(e.getPiece(i,j).getForme()=="tour"){
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"tour_blanc.png"));
JLabel img = new JLabel(icon);
plateau[j][i].add(img);
}
if(e.getPiece(i,j).getForme()=="cavalier"){
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"cavalier_blanc.png"));
JLabel img = new JLabel(icon);
plateau[j][i].add(img);
}
if(e.getPiece(i,j).getForme()=="fou"){
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"fou_blanc.png"));
JLabel img = new JLabel(icon);
plateau[j][i].add(img);
}
if(e.getPiece(i,j).getForme()=="pion"){
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"pion_blanc.png"));
JLabel img = new JLabel(icon);
plateau[j][i].add(img);
}
if(e.getPiece(i,j).getForme()=="reine"){
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"reine_blanc.png"));
JLabel img = new JLabel(icon);
plateau[j][i].add(img);
}
if(e.getPiece(i,j).getForme()=="roi"){
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"roi_blanc.png"));
JLabel img = new JLabel(icon);
plateau[j][i].add(img);
}
}
if(e.getPiece(i,j).getCouleur()=="noir"){
if(e.getPiece(i,j).getForme()=="tour"){
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"tour_noir.png"));
JLabel img = new JLabel(icon);
plateau[j][i].add(img);
}
if(e.getPiece(i,j).getForme()=="cavalier"){
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"cavalier_noir.png"));
JLabel img = new JLabel(icon);
plateau[j][i].add(img);
}
if(e.getPiece(i,j).getForme()=="fou"){
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"fou_noir.png"));
JLabel img = new JLabel(icon);
plateau[j][i].add(img);
}
if(e.getPiece(i,j).getForme()=="pion"){
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"pion_noir.png"));
JLabel img = new JLabel(icon);
plateau[j][i].add(img);
}
if(e.getPiece(i,j).getForme()=="reine"){
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"reine_noir.png"));
JLabel img = new JLabel(icon);
plateau[j][i].add(img);
}
if(e.getPiece(i,j).getForme()=="roi"){
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"roi_noir.png"));
JLabel img = new JLabel(icon);
plateau[j][i].add(img);
}
}
}
}
}
}
public void revalidate(){
for(int i=0;i<8;i++) {
for(int j=0; j<8;j++){
plateau[i][j].revalidate();
}
}
}
public void affichJoueur (String ColorJoueur){
time.setTime();
joueur.setText("Au tour du joueur " + ColorJoueur ); // Met la couleur du joueur dans le menu
time.startDTimer();
}
public JPanel getPlateau(int i, int j){ return plateau[i][j]; }
public void couleurValide(Echiquier e, Piece p){
plateau[p.getColonne()][p.getLigne()].setBackground(Color.BLUE);
for(int i=0;i<8;i++){
for(int j=0;j<8;j++){
if (e.deplacementValide(p, i, j)){
if(e.existePiece(i,j) && e.getPiece(i,j).getCouleur()!=p.getCouleur()){
plateau[j][i].setBorder(BorderFactory.createLineBorder(Color.red));
plateau[j][i].setBackground(new Color(255,0,0,100)); // rouge opaque
}
else {
plateau[j][i].setBorder(BorderFactory.createLineBorder(Color.green));
plateau[j][i].setBackground(new Color(6,160,0,100)); // vert opaque
}
}
}
}
}
public void couleurOrigine(Echiquier e){
for(int i=0;i<8;i++){
for(int j=0;j<8;j++){
if((i%2==0 && j%2==1) || (i%2==1 && j%2==0)){
plateau[i][j].setBackground(new Color(122,76,42));
plateau[i][j].setBorder(BorderFactory.createLineBorder(Color.black));
}
else {
plateau[i][j].setBackground(new Color(206,158,86));
plateau[i][j].setBorder(BorderFactory.createLineBorder(Color.black));
}
}
}
}
public void affichEchec(String couleur){
if(couleur=="blanc") JOptionPane.showMessageDialog(null, "Le roi blanc est en echec!", "ATTENTION", JOptionPane.INFORMATION_MESSAGE);
else JOptionPane.showMessageDialog(null, "Le roi noir est en echec!", "ATTENTION", JOptionPane.INFORMATION_MESSAGE);
}
public void affichGagnant(String couleur,Interface i){
if(couleur=="blanc" && i.getTimer().getTime()>=0) JOptionPane.showMessageDialog(null, "Le joueur blanc gagne la partie", "VICTOIRE", JOptionPane.INFORMATION_MESSAGE);
else if(couleur=="blanc" && i.getTimer().getTime()<0 ) JOptionPane.showMessageDialog(null, "Le joueur blanc gagne la partie car le joueur noir n'a pas jouer dans les temps", "VICTOIRE", JOptionPane.INFORMATION_MESSAGE);
else if(couleur=="noir" && i.getTimer().getTime()>=0) JOptionPane.showMessageDialog(null, "Le joueur noir gagne la partie", "VICTOIRE", JOptionPane.INFORMATION_MESSAGE);
else if(couleur=="noir" && i.getTimer().getTime()<0 ) JOptionPane.showMessageDialog(null, "Le joueur noir gagne la partie car le joueur blanc n'a pas jouer dans les temps", "VICTOIRE", JOptionPane.INFORMATION_MESSAGE);
}
public JPanel tour(String couleur){ // image de la tour pour choisir la promotion
tour=new JPanel();
tour.setLayout(new BorderLayout());
tour.setVisible(true);
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"tour_" + couleur + ".png"));
JLabel img = new JLabel(icon);
tour.add(img,BorderLayout.CENTER);
tour.addMouseListener(new MouseAdapter(){;
public void mouseClicked(MouseEvent e) {
setFormePromo("tour");
promotion.dispose();
}});
return tour;
}
public JPanel cavalier(String couleur){ // image du cavalier pour choisir la promotion
cavalier=new JPanel();
cavalier.setLayout(new BorderLayout());
cavalier.setVisible(true);
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"cavalier_" + couleur + ".png"));
JLabel img = new JLabel(icon);
cavalier.add(img,BorderLayout.CENTER);
cavalier.addMouseListener(new MouseAdapter(){;
public void mouseClicked(MouseEvent e) {
setFormePromo("cavalier");
promotion.dispose();
}});
return cavalier;
}
public JPanel fou(String couleur){ // image du fou pour choisir la promotion
fou=new JPanel();
fou.setLayout(new BorderLayout());
fou.setVisible(true);
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"fou_" + couleur + ".png"));
JLabel img = new JLabel(icon);
fou.add(img,BorderLayout.CENTER);
fou.addMouseListener(new MouseAdapter(){;
public void mouseClicked(MouseEvent e) {
setFormePromo("fou");
promotion.dispose();
}});
return fou;
}
public JPanel reine(String couleur){ // image de la reine pour choisir la promotion
reine=new JPanel();
reine.setLayout(new BorderLayout());
reine.setVisible(true);
ImageIcon icon = new ImageIcon(getClass().getResource(cheminImg+"reine_" + couleur + ".png"));
JLabel img = new JLabel(icon);
reine.add(img,BorderLayout.CENTER);
reine.addMouseListener(new MouseAdapter(){;
public void mouseClicked(MouseEvent e) {
setFormePromo("reine");
promotion.dispose();
}});
return reine;
}
public void affichPromotion(String couleur){
promotion = new JFrame();
promotion.setSize(400,310); // taille en pixel de la largeur et hauteur de la fenetre
promotion.setLayout(new GridLayout(0,2));
promotion.setLocationRelativeTo(null);
promotion.setResizable(false); // empeche le redimenssionnement de la fenetre
promotion.setTitle(" Promotion d'un pion " + couleur);
promotion.add(tour(couleur));
promotion.add(cavalier(couleur));
promotion.add(fou(couleur));
promotion.add(reine(couleur));
promotion.setVisible(true);
}
public String getFormePromo(){
return formePromo;
}
public void setFormePromo(String promo){
formePromo=promo;
}
}