Amélioration
This commit is contained in:
parent
cdcbc4f485
commit
dfd9b1169e
@ -43,6 +43,8 @@ public class GMCase extends JPanel {
|
||||
actionButton.setContentAreaFilled(false);
|
||||
actionButton.setBorderPainted(false);
|
||||
actionButton.setPreferredSize(new Dimension(50, 50));
|
||||
Font buttonFont = actionButton.getFont();
|
||||
actionButton.setFont(new Font(buttonFont.getName(), Font.PLAIN, 60));
|
||||
|
||||
BorderLayout gestionnaire = new BorderLayout();
|
||||
setLayout(gestionnaire);
|
||||
|
@ -10,7 +10,6 @@ import javax.swing.*;
|
||||
public class GMChecker {
|
||||
|
||||
private GMGrid grid;
|
||||
private GMCheckerListener checkerListener;
|
||||
|
||||
/**
|
||||
* Constructeur pour créer une instance de GMChecker.
|
||||
@ -18,7 +17,6 @@ public class GMChecker {
|
||||
*/
|
||||
public GMChecker(GMGrid grid) {
|
||||
this.grid = grid;
|
||||
this.checkerListener = new GMCheckerListener(this);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,28 +0,0 @@
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
* La classe GMCheckerListener est utilisée pour gérer les événements liés à la vérification de la grille.
|
||||
*/
|
||||
public class GMCheckerListener implements ActionListener {
|
||||
|
||||
private GMChecker gridMakerChecker;
|
||||
|
||||
/**
|
||||
* Constructeur de GMCheckerListener.
|
||||
* @param gridMakerChecker L'instance de GMChecker à utiliser.
|
||||
*/
|
||||
public GMCheckerListener(GMChecker gridMakerChecker) {
|
||||
this.gridMakerChecker = gridMakerChecker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Méthode invoquée lorsque le bouton "Vérifier" est cliqué.
|
||||
* Lance la vérification de la grille.
|
||||
* @param e L'événement d'action
|
||||
*/
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
gridMakerChecker.checkGridMessage();
|
||||
}
|
||||
}
|
@ -39,9 +39,6 @@ public class GMUserInterfaceView {
|
||||
JMenuItem nouveauItem = createMenuItem("Nouveau", new GMResetGrid(grid));
|
||||
JMenuItem chargerItem = createMenuItem("Charger", new GMImport(window, grid));
|
||||
JMenuItem sauvegarderItem = createMenuItem("Sauvegarder", new GMSaverActionListener(window, grid));
|
||||
GMChecker checker = new GMChecker(grid); // Créez une instance de GMChecker
|
||||
GMCheckerListener checkerListener = new GMCheckerListener(checker); // Créez une instance de GMCheckerListener en passant GMChecker en argument
|
||||
JMenuItem verifierItem = createMenuItem("Vérifier", checkerListener);
|
||||
JMenuItem aideGrilleItem = createMenuItem("Comment créer une grille", new GMHowToCreateController());
|
||||
JMenuItem reglesSudokuItem = createMenuItem("Règles du Sudoku", new GMRules());
|
||||
|
||||
@ -60,7 +57,6 @@ public class GMUserInterfaceView {
|
||||
menuFichier.add(nouveauItem);
|
||||
menuFichier.add(chargerItem);
|
||||
menuFichier.add(sauvegarderItem);
|
||||
menuGrille.add(verifierItem);
|
||||
menuAide.add(aideGrilleItem);
|
||||
menuAide.add(reglesSudokuItem);
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
import java.awt.Color;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JLabel;
|
||||
import java.awt.Font;
|
||||
|
||||
/**
|
||||
* GSCase représente une case dans une grille de jeu.
|
||||
@ -56,9 +57,12 @@ public class GSCase extends JPanel {
|
||||
* Initialise la case avec une valeur initiale.
|
||||
*/
|
||||
public void initializeCell() {
|
||||
Font font = label.getFont();
|
||||
label.setFont(font.deriveFont(font.getSize() + 15f));
|
||||
|
||||
label.setText(this.text);
|
||||
this.setBackground(this.isInitial ? Color.lightGray : Color.white);
|
||||
layoutSetup();
|
||||
layoutSetup();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -115,18 +119,18 @@ public class GSCase extends JPanel {
|
||||
} else if (this.digitCount == 1 && value != this.primaryValue) {
|
||||
this.secondaryValue = value;
|
||||
this.digitCount++;
|
||||
this.text = String.valueOf(this.primaryValue + ", " + this.secondaryValue);
|
||||
this.text = String.valueOf(this.primaryValue + " " + this.secondaryValue);
|
||||
} else if (this.digitCount == 2 && value != this.primaryValue && value != this.secondaryValue) {
|
||||
this.tertiaryValue = value;
|
||||
this.digitCount++;
|
||||
this.text = String.valueOf(this.primaryValue + ", " + this.secondaryValue + ", " + this.tertiaryValue);
|
||||
this.text = String.valueOf(this.primaryValue + " " + this.secondaryValue + " " + this.tertiaryValue);
|
||||
} else if (this.digitCount == 3 && value != this.primaryValue && value != this.secondaryValue && value != this.tertiaryValue) {
|
||||
this.quaternaryValue = value;
|
||||
this.digitCount++;
|
||||
this.text = String.valueOf(this.primaryValue + ", " + this.secondaryValue + ", " + this.tertiaryValue + ", " + this.quaternaryValue);
|
||||
this.text = String.valueOf(this.primaryValue + " " + this.secondaryValue + " " + this.tertiaryValue + " " + this.quaternaryValue);
|
||||
}
|
||||
}
|
||||
this.setBackground(Color.WHITE);
|
||||
this.setBackground(Color.PINK);
|
||||
layoutSetup();
|
||||
} else if (checkInputValue(value)){
|
||||
this.setBackground(Color.RED);
|
||||
|
Loading…
Reference in New Issue
Block a user