-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFenetreJoueur.java
More file actions
93 lines (72 loc) · 2.72 KB
/
FenetreJoueur.java
File metadata and controls
93 lines (72 loc) · 2.72 KB
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
import javax.swing.*;
import java.awt.*;
import java.util.Random;
/* Classe FenetreJoueur qui est une JFrame
* @author BOULLIER Arthur
* @author GONIN-SAGET Allan
*/
public class FenetreJoueur extends JFrame {
//hautuer de la fenetre
static int hauteur = 600;
//largueur de la fenetre
static int largeur = 950;
JProgressBar progressBar = null;
public Grille grille;
/*
* Constructeur de la classe FenetreJoueur
*/
public FenetreJoueur(Joueur jeSuisJoueur){
//choix du titre de la fenetre
super("XxXx__TicTacToe__xXxX");
//choix du layout de la fenetre
this.setLayout(new GridLayout());
//On decide de tout quitter si on ferme la fenetre (classique)
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//On definit la taille de la fenetre
this.setSize(new Dimension(largeur,hauteur));
//Création de la zone de chat
AffichageChat zoneChat = new AffichageChat(jeSuisJoueur.getIcone());
AffichageJeu zoneJeu = new AffichageJeu(jeSuisJoueur);
JPanel panelTotal = new JPanel();
panelTotal.setLayout(new GridLayout(1,2));
panelTotal.add(zoneJeu);
panelTotal.add(zoneChat);
panelTotal.setBorder(BorderFactory.createEmptyBorder(25,25,25,25));
//On ajoute nos deux zones a la fenetre
this.add(panelTotal);
UIManager.put("Label.font", new Font("Liberation Serif",Font.PLAIN,18));
try {
UIManager.setLookAndFeel( "com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (Exception e) {
try {
UIManager.setLookAndFeel(UIManager
.getSystemLookAndFeelClassName());
} catch (Exception ex) {
e.printStackTrace();
System.out.println("Erreur dans le thème");
}
}
SwingUtilities.updateComponentTreeUI(this);
this.repaint();
this.setVisible(true);
this.setResizable(false);
}
public void resetProgressBar(){
this.progressBar.setValue(0);
}
public void avanceProgressBar(){
int currentValue = progressBar.getValue();
int newValue = currentValue + (int)(progressBar.getMaximum() * 0.1);
this.progressBar.setValue(newValue);
}
public static void main(String[] args){
//Si il y a un argument dans le main, on prend ce caractere comme nom de joueur
if(args.length > 0){
new FenetreJoueur(new Joueur(args[0].charAt(0)));
return;
}
Random r = new Random();
char choix = (char)(r.nextInt(26) + 'A');
new FenetreJoueur(new Joueur(choix));
}
}