SAE21_2021/Banniere.java

48 lines
1.2 KiB
Java

import javax.swing.*;
import java.awt.*;
public class Banniere extends JPanel {
private FrameJeu fenetre;
// Définition du constructeur
public Banniere(int mines, FrameJeu fenetre) {
super();
this.fenetre=fenetre;
// On défini un style à la bannière
this.setBackground( new Color(0, 236, 96));
// TODO : Bouton sauver et quitter
}
// Méthode pour afficher le nombre de mines restantes
public void setMinesLeft(int minesLeft){
this.removeAll();
this.add(new MineLeft(minesLeft,this.getSize()));
this.repaint();
}
// Méthode pour indiquer au joueur sa Victoire
public void setVictoire(){
this.add(new Fin("Victoire !",this.getSize()));
this.repaint();
try {
Thread.sleep(5000);
} catch (InterruptedException e){
System.out.println("oops you didn't see the end");
}
new FrameMenu();
this.fenetre.dispose();
}
// Méthode pour indiquer au joueur sa Défaite
public void setDefaite(){
this.add(new Fin("Défaite !",this.getSize()));
this.repaint();try {
Thread.sleep(5000);
} catch (InterruptedException e){
System.out.println("oops you didn't see the end");
}
new FrameMenu();
this.fenetre.dispose();
}
}