probleme avec ActionListener ????git commit -m!
This commit is contained in:
parent
14e046f4dd
commit
9c0bc0faa8
4
ActionListener.java
Normal file
4
ActionListener.java
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
public interface ActionListener {
|
||||||
|
|
||||||
|
}
|
@ -4,38 +4,38 @@ import java.awt.*;
|
|||||||
public class Banniere extends JPanel {
|
public class Banniere extends JPanel {
|
||||||
private FrameJeu fenetre;
|
private FrameJeu fenetre;
|
||||||
private FrameMenu menu;
|
private FrameMenu menu;
|
||||||
|
private JButton save;
|
||||||
// Définition du constructeur
|
// Définition du constructeur
|
||||||
public Banniere(int mines, FrameJeu fenetre, FrameMenu menu, Dimension grilleSize) {
|
public Banniere(int mines, FrameJeu fenetre, FrameMenu menu, Grille grille) {
|
||||||
super();
|
super();
|
||||||
this.fenetre=fenetre;
|
this.fenetre=fenetre;
|
||||||
this.menu=menu;
|
this.menu=menu;
|
||||||
this.setSize(grilleSize.width,grilleSize.height/8);
|
this.setSize(grille.getWidth(),grille.getHeight()/8);
|
||||||
|
|
||||||
// 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));
|
||||||
|
this.setLayout(new BorderLayout());
|
||||||
|
|
||||||
// Bouton pour sauver et quitter
|
// Bouton pour sauver et quitter
|
||||||
JButton save = new JButton("Sauver et quitter");
|
this.save = new JButton("Sauver et quitter");
|
||||||
//save.addActionListener(new SaveListener());
|
//save.addActionListener(new SaveListener(grille));
|
||||||
this.add(save, BorderLayout.EAST);
|
this.add(this.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) {
|
||||||
JLabel mines = new JLabel("Mines restantes : "+Integer.toString(minesLeft));
|
JLabel mines = new JLabel("Mines restantes : "+Integer.toString(minesLeft));
|
||||||
Dimension prefSize = new Dimension(this.getWidth()/2,this.getHeight()/5);
|
this.add(mines, BorderLayout.NORTH);
|
||||||
mines.setPreferredSize(prefSize);
|
|
||||||
this.add(mines,BorderLayout.NORTH);
|
|
||||||
this.repaint();
|
this.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Méthode pour indiquer au joueur sa Victoire
|
// Méthode pour indiquer au joueur sa Victoire
|
||||||
public void setVictoire() {
|
public void setVictoire() {
|
||||||
|
remove(this.save);
|
||||||
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));
|
||||||
victoire.setFont(new Font("Arial", Font.PLAIN, 30));
|
victoire.setFont(new Font("Arial", Font.PLAIN, 30));
|
||||||
this.add(victoire,BorderLayout.CENTER);
|
this.add(victoire, BorderLayout.CENTER);
|
||||||
Timer timerMenu = new Timer(7000, new MenuListener(this.fenetre, this.menu));
|
Timer timerMenu = new Timer(7000, new MenuListener(this.fenetre, this.menu));
|
||||||
timerMenu.setRepeats(false);
|
timerMenu.setRepeats(false);
|
||||||
timerMenu.start();
|
timerMenu.start();
|
||||||
@ -43,10 +43,11 @@ public class Banniere extends JPanel {
|
|||||||
|
|
||||||
// Méthode pour indiquer au joueur sa Défaite
|
// Méthode pour indiquer au joueur sa Défaite
|
||||||
public void setDefaite() {
|
public void setDefaite() {
|
||||||
|
remove(this.save);
|
||||||
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));
|
||||||
defaite.setFont(new Font("Arial", Font.PLAIN, 30));
|
defaite.setFont(new Font("Arial", Font.PLAIN, 30));
|
||||||
this.add(defaite,BorderLayout.CENTER);
|
this.add(defaite, BorderLayout.CENTER);
|
||||||
Timer timerMenu = new Timer(7000, new MenuListener(this.fenetre, this.menu));
|
Timer timerMenu = new Timer(7000, new MenuListener(this.fenetre, this.menu));
|
||||||
timerMenu.setRepeats(false);
|
timerMenu.setRepeats(false);
|
||||||
timerMenu.start();
|
timerMenu.start();
|
||||||
|
@ -33,7 +33,7 @@ public class Grille extends JPanel{
|
|||||||
this.grilleSize = new Dimension(((screenSize.height*3/4)/lignes)*colonnes, screenSize.height*3/4 );
|
this.grilleSize = new Dimension(((screenSize.height*3/4)/lignes)*colonnes, screenSize.height*3/4 );
|
||||||
Dimension caseSize = new Dimension(this.grilleSize.height/lignes,this.grilleSize.height/lignes);
|
Dimension caseSize = new Dimension(this.grilleSize.height/lignes,this.grilleSize.height/lignes);
|
||||||
GridLayout damier = new GridLayout(lignes,colonnes);
|
GridLayout damier = new GridLayout(lignes,colonnes);
|
||||||
Banniere banniere = new Banniere(mines,this.fenetre, menu, grilleSize);
|
Banniere banniere = new Banniere(mines,this.fenetre, menu, this);
|
||||||
this.banniere=banniere;
|
this.banniere=banniere;
|
||||||
this.setLayout(damier);
|
this.setLayout(damier);
|
||||||
this.setSize(grilleSize);
|
this.setSize(grilleSize);
|
||||||
|
@ -6,6 +6,8 @@ public class MenuListener implements ActionListener{
|
|||||||
this.fenetre=fenetre;
|
this.fenetre=fenetre;
|
||||||
this.menu=menu;
|
this.menu=menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void actionPerformed(ActionEvent event){
|
public void actionPerformed(ActionEvent event){
|
||||||
this.menu.setVisible(true);
|
this.menu.setVisible(true);
|
||||||
this.fenetre.dispose();
|
this.fenetre.dispose();
|
||||||
|
@ -4,6 +4,8 @@ public class NewGameListener implements ActionListener{
|
|||||||
public NewGameListener(FrameMenu menu){
|
public NewGameListener(FrameMenu menu){
|
||||||
this.menu=menu;
|
this.menu=menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void actionPerformed(ActionEvent event){
|
public void actionPerformed(ActionEvent event){
|
||||||
int[] settings =this.menu.getSettings();
|
int[] settings =this.menu.getSettings();
|
||||||
new FrameJeu(settings[0], settings[1], settings[2], this.menu);
|
new FrameJeu(settings[0], settings[1], settings[2], this.menu);
|
||||||
|
@ -10,6 +10,8 @@ public class SettingsListener implements ChangeListener{
|
|||||||
this.settingToSet=settingToSet;
|
this.settingToSet=settingToSet;
|
||||||
this.menu=menu;
|
this.menu=menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void stateChanged(ChangeEvent evenement) {
|
public void stateChanged(ChangeEvent evenement) {
|
||||||
JSlider slider = (JSlider) evenement.getSource();
|
JSlider slider = (JSlider) evenement.getSource();
|
||||||
settingValue=slider.getValue();
|
settingValue=slider.getValue();
|
||||||
|
Loading…
Reference in New Issue
Block a user