ajout bouton save

This commit is contained in:
Haïssous Kayyissa 2022-05-24 21:46:09 +02:00
parent f8e68436b0
commit 14e046f4dd
4 changed files with 16 additions and 32 deletions

Binary file not shown.

View File

@ -14,13 +14,19 @@ public class Banniere extends JPanel {
// On défini un style à la bannière // On défini un style à la bannière
this.setBackground(new Color(0, 236, 96)); this.setBackground(new Color(0, 236, 96));
// TODO : Bouton sauver et quitter // 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());
} }
// Méthode pour afficher le nombre de mines restantes // Méthode pour afficher le nombre de mines restantes
public void setMinesLeft(int minesLeft) { public void setMinesLeft(int minesLeft) {
this.removeAll(); JLabel mines = new JLabel("Mines restantes : "+Integer.toString(minesLeft));
this.add(new JLabel("Mines restantes : "+Integer.toString(minesLeft)),BorderLayout.CENTER); Dimension prefSize = new Dimension(this.getWidth()/2,this.getHeight()/5);
mines.setPreferredSize(prefSize);
this.add(mines,BorderLayout.NORTH);
this.repaint(); this.repaint();
} }
@ -28,8 +34,9 @@ public class Banniere extends JPanel {
public void setVictoire() { public void setVictoire() {
JLabel victoire = new JLabel("Victoire ! Retour au menu..."); JLabel victoire = new JLabel("Victoire ! Retour au menu...");
victoire.setForeground(new Color(0, 22, 236)); victoire.setForeground(new Color(0, 22, 236));
this.add(victoire,BorderLayout.SOUTH); victoire.setFont(new Font("Arial", Font.PLAIN, 30));
Timer timerMenu = new Timer(5000, new MenuListener(this.fenetre, this.menu)); this.add(victoire,BorderLayout.CENTER);
Timer timerMenu = new Timer(7000, new MenuListener(this.fenetre, this.menu));
timerMenu.setRepeats(false); timerMenu.setRepeats(false);
timerMenu.start(); timerMenu.start();
} }
@ -38,8 +45,9 @@ public class Banniere extends JPanel {
public void setDefaite() { public void setDefaite() {
JLabel defaite = new JLabel("Défaite ! Retour au menu..."); JLabel defaite = new JLabel("Défaite ! Retour au menu...");
defaite.setForeground(new Color(0, 22, 236)); defaite.setForeground(new Color(0, 22, 236));
this.add(defaite,BorderLayout.SOUTH); defaite.setFont(new Font("Arial", Font.PLAIN, 30));
Timer timerMenu = new Timer(5000, new MenuListener(this.fenetre, this.menu)); this.add(defaite,BorderLayout.CENTER);
Timer timerMenu = new Timer(7000, new MenuListener(this.fenetre, this.menu));
timerMenu.setRepeats(false); timerMenu.setRepeats(false);
timerMenu.start(); timerMenu.start();
} }

View File

@ -1,21 +0,0 @@
import javax.swing.JComponent;
import java.awt.*;
public class Fin extends JComponent {
private String message;
private Dimension banniereSize;
public Fin(String message, Dimension banniereSize) {
super();
this.message = message;
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(message,banniereSize.width/100,banniereSize.height*2/3);
}
}

View File

@ -26,15 +26,12 @@ FrameJeu.class : FrameJeu.java Grille.class
Grille.class : Grille.java Banniere.class Case.class Grille.class : Grille.java Banniere.class Case.class
${JC} ${JCFLAGS} Grille.java ${JC} ${JCFLAGS} Grille.java
Banniere.class : Banniere.java MenuListener.class Fin.class Banniere.class : Banniere.java MenuListener.class
${JC} ${JCFLAGS} Banniere.java ${JC} ${JCFLAGS} Banniere.java
Case.class : Case.java ListenerCase.class Entourage.class Case.class : Case.java ListenerCase.class Entourage.class
${JC} ${JCFLAGS} Case.java ${JC} ${JCFLAGS} Case.java
Fin.class : Fin.java
${JC} ${JCFLAGS} Fin.java
MenuListener.class : MenuListener.java MenuListener.class : MenuListener.java
${JC} ${JCFLAGS} MenuListener.java ${JC} ${JCFLAGS} MenuListener.java