MAJ boutons P4

This commit is contained in:
dagorne 2022-10-18 13:52:42 +02:00
parent 957591d90e
commit 4fdd34dca2
4 changed files with 52 additions and 13 deletions

View File

@ -41,6 +41,11 @@ build/$(PACKAGE_PATH)/Event/AbstractGridInitiater.class : src/$(PACKAGE_PATH)/Ev
#------- Controleur ------
build/$(PACKAGE_PATH)/Controller/ResetGame.class : src/$(PACKAGE_PATH)/Controller/ResetGame.java \
build/$(PACKAGE_PATH)/View/Grille.class \
build/$(PACKAGE_PATH)/Model/GrilleModel.class
javac $(JAVAC_OPT) $<
build/$(PACKAGE_PATH)/Controller/GrilleMouseListener.class : src/$(PACKAGE_PATH)/Controller/GrilleMouseListener.java \
build/$(PACKAGE_PATH)/View/Grille.class \
build/$(PACKAGE_PATH)/Model/GrilleModel.class \
@ -83,6 +88,7 @@ build/$(PACKAGE_PATH)/View/Grille.class : src/$(PACKAGE_PATH)/View/Grille.java \
build/$(PACKAGE_PATH)/View/Puissance4Panel.class : src/$(PACKAGE_PATH)/View/Puissance4Panel.java \
build/$(PACKAGE_PATH)/View/Pion.class \
build/$(PACKAGE_PATH)/View/Grille.class \
build/$(PACKAGE_PATH)/Controller/ResetGame.class \
$(Controller)
javac $(JAVAC_OPT) $<

View File

@ -29,12 +29,5 @@ public class GrilleMouseListener extends MouseInputAdapter{
this.modele.verifyColumn(column);
}
}
//Seulement pour cas de test (Doit être modifié)
else {
this.modele.reset();
this.grille.reset();
}
}
}

View File

@ -0,0 +1,29 @@
package fr.iutfbleau.projetAgile.Controller;
import javax.swing.*;
import java.awt.event.*;
import fr.iutfbleau.projetAgile.Model.GrilleModel;
import fr.iutfbleau.projetAgile.View.Grille;
public class ResetGame implements ActionListener {
/**
* obligatoire car test implémente l'interface ActionListener
*/
private Grille grille;
private GrilleModel modele;
public ResetGame(Grille grille, GrilleModel modele){
this.grille = grille;
this.modele = modele;
}
@Override
public void actionPerformed(ActionEvent e) {
this.modele.reset();
this.grille.reset();
}
}

View File

@ -1,9 +1,12 @@
package fr.iutfbleau.projetAgile.View;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import fr.iutfbleau.projetAgile.Controller.GrilleMouseListener;
import fr.iutfbleau.projetAgile.Controller.ModelEventListener;
import fr.iutfbleau.projetAgile.Controller.ResetGame;
import fr.iutfbleau.projetAgile.Model.GrilleModel;
public class Puissance4Panel extends JPanel{
@ -15,13 +18,15 @@ public class Puissance4Panel extends JPanel{
public Puissance4Panel() {
super();
this.reset = new JButton("recommencer");
this.menu = new JButton("Accueil");
this.reset = new JButton("RECOMMENCER");
this.menu = new JButton("ACCUEIL");
this.label = new JLabel("TOUR DU JOUEUR 1");
this.grille = new Grille();
GrilleModel gm = new GrilleModel();
GrilleMouseListener listener = new GrilleMouseListener(this.grille, gm);
ResetGame resetGame = new ResetGame(grille, gm);
reset.addActionListener(resetGame);
ModelEventListener mel = new ModelEventListener(this.grille);
this.grille.addMouseListener(listener);
gm.addGridListener(mel);
@ -39,7 +44,7 @@ public class Puissance4Panel extends JPanel{
gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.CENTER;
gbc.anchor = GridBagConstraints.WEST;
gbc.gridwidth = 1;
gbc.gridheight = 1;
gbc.weightx = 0;
@ -51,6 +56,7 @@ public class Puissance4Panel extends JPanel{
JLabel titre = new JLabel("PUISSANCE 4");
titre.setForeground(Color.WHITE);
titre.setFont(new Font("",Font.BOLD, 40));
gbc.gridx = 1;
gbc.gridy = 0;
@ -83,19 +89,24 @@ public class Puissance4Panel extends JPanel{
gbc.gridy = 2;
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.CENTER;
gbc.gridwidth = 1;
gbc.gridwidth = 1;
gbc.gridheight = 1;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.insets = new Insets(0, 0, 0, 0);
gbc.insets = new Insets(50, 0, 0, 0);
panneauBas.setOpaque(false);
label.setForeground(Color.WHITE);
label.setFont(new Font("",Font.BOLD, 20));
this.add(panneauBas, gbc);
reset.setBackground(new Color(255,64,64));
reset.setForeground(Color.WHITE);
reset.setBorder(BorderFactory.createEmptyBorder(5,10,5,10));
reset.setBorder(new EmptyBorder(5,10,5,10));
menu.setBackground(new Color(255,64,64));
menu.setForeground(Color.WHITE);
menu.setBorder(new EmptyBorder(5,10,5,10));
}
public Grille getGrille() {