menu un peu plus beau + nettoyage

This commit is contained in:
Haïssous Kayyissa 2022-05-23 22:18:52 +02:00
parent 1b6af2fa83
commit bc345cfc93
3 changed files with 0 additions and 88 deletions

View File

@ -1,20 +0,0 @@
import javax.swing.*;
import java.awt.*;
public class EtatPartie extends JPanel {
// Définition du constructeur
public EtatPartie(int mines) {
super();
// On défini un style à la bannière
this.setBackground( new Color(0, 236, 96));
}
// 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();
this.updateUI();
}
}

View File

@ -1,47 +0,0 @@
import javax.swing.*;
import java.awt.*;
public class Fond extends JPanel{
public Fond(JFrame fenetre) {
// On créer un damier aux couleurs du démineur pour le fond
// Découpage de la fenêtre pour la mise en place du damier
Dimension damierSize = fenetre.getSize();
Dimension gridSize = new Dimension(damierSize.width/75, damierSize.height/75);
GridLayout layoutDamier = new GridLayout(gridSize.height, gridSize.width);
this.setLayout(layoutDamier);
this.setSize(damierSize);
// Création des couleurs
Color gray1 = new Color(70,70,70);
Color gray2 = new Color(60,60,60);
// Réalisation du damier et ajout d'éléments graphiques
for (int line=0; line<gridSize.height; line++){
for(int cases = 0; cases < gridSize.width; cases++){
if (line%2==0){
if (cases%2==0){
JPanel dark = new JPanel();
dark.setBackground(gray2);
this.add(dark);
} else {
JPanel light = new JPanel();
light.setBackground(gray1);
this.add(light);
}
} else {
if (cases%2==0){
JPanel light = new JPanel();
light.setBackground(gray1);
this.add(light);
} else {
JPanel dark = new JPanel();
dark.setBackground(gray2);
this.add(dark);
}
}
}
}
}
}

View File

@ -1,21 +0,0 @@
import javax.swing.JComponent;
import java.awt.*;
public class MineLeft extends JComponent {
private int minesLeft;
private Dimension banniereSize;
public MineLeft(int minesLeft, Dimension banniereSize) {
super();
this.minesLeft = minesLeft;
this.banniereSize=banniereSize;
}
@Override
protected void paintComponent(Graphics pinceau) {
this.setSize(banniereSize);
Graphics chiffre = pinceau.create();
Font font = new Font("Arial", Font.BOLD, banniereSize.width/50);
chiffre.setFont(font);
chiffre.setColor(new Color(0, 22, 236));
chiffre.drawString("Mines restantes : "+Integer.toString(this.minesLeft),banniereSize.width/100,banniereSize.height*2/3);
}
}