2022-05-21 17:53:19 +02:00
|
|
|
import javax.swing.*;
|
|
|
|
import java.awt.*;
|
|
|
|
|
|
|
|
public class Banniere extends JPanel {
|
2022-05-21 22:17:25 +02:00
|
|
|
private FrameJeu fenetre;
|
2022-05-23 19:32:09 +02:00
|
|
|
private FrameMenu menu;
|
2022-05-21 17:53:19 +02:00
|
|
|
// Définition du constructeur
|
2022-05-24 13:49:09 +02:00
|
|
|
public Banniere(int mines, FrameJeu fenetre, FrameMenu menu, Dimension grilleSize) {
|
2022-05-21 17:53:19 +02:00
|
|
|
super();
|
2022-05-21 22:17:25 +02:00
|
|
|
this.fenetre=fenetre;
|
2022-05-23 19:32:09 +02:00
|
|
|
this.menu=menu;
|
2022-05-24 13:49:09 +02:00
|
|
|
this.setSize(grilleSize.width,grilleSize.height/8);
|
2022-05-21 17:53:19 +02:00
|
|
|
|
|
|
|
// On défini un style à la bannière
|
2022-05-23 23:02:19 +02:00
|
|
|
this.setBackground(new Color(0, 236, 96));
|
2022-05-21 18:41:24 +02:00
|
|
|
|
2022-05-24 21:46:09 +02:00
|
|
|
// Bouton pour sauver et quitter
|
|
|
|
JButton save = new JButton("Sauver et quitter");
|
|
|
|
//save.addActionListener(new SaveListener());
|
|
|
|
this.add(save, BorderLayout.EAST);
|
|
|
|
System.out.println(save.getLocation());
|
2022-05-21 17:53:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Méthode pour afficher le nombre de mines restantes
|
2022-05-24 16:15:21 +02:00
|
|
|
public void setMinesLeft(int minesLeft) {
|
2022-05-24 21:46:09 +02:00
|
|
|
JLabel mines = new JLabel("Mines restantes : "+Integer.toString(minesLeft));
|
|
|
|
Dimension prefSize = new Dimension(this.getWidth()/2,this.getHeight()/5);
|
|
|
|
mines.setPreferredSize(prefSize);
|
|
|
|
this.add(mines,BorderLayout.NORTH);
|
2022-05-21 17:53:19 +02:00
|
|
|
this.repaint();
|
2022-05-21 18:41:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Méthode pour indiquer au joueur sa Victoire
|
2022-05-24 16:15:21 +02:00
|
|
|
public void setVictoire() {
|
|
|
|
JLabel victoire = new JLabel("Victoire ! Retour au menu...");
|
|
|
|
victoire.setForeground(new Color(0, 22, 236));
|
2022-05-24 21:46:09 +02:00
|
|
|
victoire.setFont(new Font("Arial", Font.PLAIN, 30));
|
|
|
|
this.add(victoire,BorderLayout.CENTER);
|
|
|
|
Timer timerMenu = new Timer(7000, new MenuListener(this.fenetre, this.menu));
|
2022-05-23 16:10:45 +02:00
|
|
|
timerMenu.setRepeats(false);
|
|
|
|
timerMenu.start();
|
2022-05-21 18:41:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Méthode pour indiquer au joueur sa Défaite
|
2022-05-24 16:15:21 +02:00
|
|
|
public void setDefaite() {
|
|
|
|
JLabel defaite = new JLabel("Défaite ! Retour au menu...");
|
|
|
|
defaite.setForeground(new Color(0, 22, 236));
|
2022-05-24 21:46:09 +02:00
|
|
|
defaite.setFont(new Font("Arial", Font.PLAIN, 30));
|
|
|
|
this.add(defaite,BorderLayout.CENTER);
|
|
|
|
Timer timerMenu = new Timer(7000, new MenuListener(this.fenetre, this.menu));
|
2022-05-23 16:10:45 +02:00
|
|
|
timerMenu.setRepeats(false);
|
|
|
|
timerMenu.start();
|
2022-05-21 17:53:19 +02:00
|
|
|
}
|
|
|
|
}
|