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 {
|
||||
private FrameJeu fenetre;
|
||||
private FrameMenu menu;
|
||||
private JButton save;
|
||||
// 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();
|
||||
this.fenetre=fenetre;
|
||||
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
|
||||
this.setBackground(new Color(0, 236, 96));
|
||||
this.setLayout(new BorderLayout());
|
||||
|
||||
// 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());
|
||||
this.save = new JButton("Sauver et quitter");
|
||||
//save.addActionListener(new SaveListener(grille));
|
||||
this.add(this.save, BorderLayout.EAST);
|
||||
}
|
||||
|
||||
// Méthode pour afficher le nombre de mines restantes
|
||||
public void setMinesLeft(int minesLeft) {
|
||||
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);
|
||||
this.add(mines, BorderLayout.NORTH);
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
// Méthode pour indiquer au joueur sa Victoire
|
||||
public void setVictoire() {
|
||||
remove(this.save);
|
||||
JLabel victoire = new JLabel("Victoire ! Retour au menu...");
|
||||
victoire.setForeground(new Color(0, 22, 236));
|
||||
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));
|
||||
timerMenu.setRepeats(false);
|
||||
timerMenu.start();
|
||||
@ -43,10 +43,11 @@ public class Banniere extends JPanel {
|
||||
|
||||
// Méthode pour indiquer au joueur sa Défaite
|
||||
public void setDefaite() {
|
||||
remove(this.save);
|
||||
JLabel defaite = new JLabel("Défaite ! Retour au menu...");
|
||||
defaite.setForeground(new Color(0, 22, 236));
|
||||
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));
|
||||
timerMenu.setRepeats(false);
|
||||
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 );
|
||||
Dimension caseSize = new Dimension(this.grilleSize.height/lignes,this.grilleSize.height/lignes);
|
||||
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.setLayout(damier);
|
||||
this.setSize(grilleSize);
|
||||
|
@ -6,6 +6,8 @@ public class MenuListener implements ActionListener{
|
||||
this.fenetre=fenetre;
|
||||
this.menu=menu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event){
|
||||
this.menu.setVisible(true);
|
||||
this.fenetre.dispose();
|
||||
|
@ -4,6 +4,8 @@ public class NewGameListener implements ActionListener{
|
||||
public NewGameListener(FrameMenu menu){
|
||||
this.menu=menu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event){
|
||||
int[] settings =this.menu.getSettings();
|
||||
new FrameJeu(settings[0], settings[1], settings[2], this.menu);
|
||||
|
@ -10,6 +10,8 @@ public class SettingsListener implements ChangeListener{
|
||||
this.settingToSet=settingToSet;
|
||||
this.menu=menu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent evenement) {
|
||||
JSlider slider = (JSlider) evenement.getSource();
|
||||
settingValue=slider.getValue();
|
||||
|
Loading…
Reference in New Issue
Block a user