Auto
This commit is contained in:
parent
3f73c761a6
commit
8bee2d784a
BIN
Enter.class
BIN
Enter.class
Binary file not shown.
17
Enter.java
17
Enter.java
@ -53,6 +53,21 @@ public class Enter extends JPanel {
|
|||||||
protected void paintComponent(Graphics g) {
|
protected void paintComponent(Graphics g) {
|
||||||
super.paintComponent(g);
|
super.paintComponent(g);
|
||||||
|
|
||||||
|
// Dessiner les contours de la grille (en gras)
|
||||||
|
Graphics2D g2d = (Graphics2D) g;
|
||||||
|
Stroke oldStroke = g2d.getStroke(); // Sauvegarder le style de ligne précédent
|
||||||
|
g2d.setStroke(new BasicStroke(4)); // Épaisseur de ligne de 4 pixels
|
||||||
|
|
||||||
|
for (int i = 0; i <= GRID_SIZE * REGION_SIZE; i++) {
|
||||||
|
if (i % REGION_SIZE == 0) {
|
||||||
|
g2d.drawLine(0, i * CELL_SIZE, GRID_SIZE * REGION_SIZE * CELL_SIZE, i * CELL_SIZE);
|
||||||
|
g2d.drawLine(i * CELL_SIZE, 0, i * CELL_SIZE, GRID_SIZE * REGION_SIZE * CELL_SIZE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rétablir le style de ligne précédent
|
||||||
|
g2d.setStroke(oldStroke);
|
||||||
|
|
||||||
// Dessiner les cases de la grille
|
// Dessiner les cases de la grille
|
||||||
for (int i = 0; i < GRID_SIZE * REGION_SIZE; i++) {
|
for (int i = 0; i < GRID_SIZE * REGION_SIZE; i++) {
|
||||||
for (int j = 0; j < GRID_SIZE * REGION_SIZE; j++) {
|
for (int j = 0; j < GRID_SIZE * REGION_SIZE; j++) {
|
||||||
@ -65,4 +80,6 @@ public class Enter extends JPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
BIN
Main.class
BIN
Main.class
Binary file not shown.
15
Main.java
15
Main.java
@ -1,4 +1,6 @@
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@ -10,7 +12,18 @@ public class Main {
|
|||||||
JFrame frame = new JFrame("Sudoku");
|
JFrame frame = new JFrame("Sudoku");
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
Enter enterPanel = new Enter(grid); // Utilisation de la classe Enter pour permettre la saisie des valeurs
|
Enter enterPanel = new Enter(grid); // Utilisation de la classe Enter pour permettre la saisie des valeurs
|
||||||
frame.add(enterPanel);
|
|
||||||
|
// Ajout de deux boutons
|
||||||
|
JButton solveButton = new JButton("Solve");
|
||||||
|
JButton resetButton = new JButton("Reset");
|
||||||
|
JPanel buttonPanel = new JPanel();
|
||||||
|
buttonPanel.add(solveButton);
|
||||||
|
buttonPanel.add(resetButton);
|
||||||
|
|
||||||
|
// Ajout des composants au frame
|
||||||
|
frame.add(enterPanel, BorderLayout.CENTER);
|
||||||
|
frame.add(buttonPanel, BorderLayout.SOUTH);
|
||||||
|
|
||||||
frame.pack();
|
frame.pack();
|
||||||
frame.setLocationRelativeTo(null); // Centrer la fenêtre sur l'écran
|
frame.setLocationRelativeTo(null); // Centrer la fenêtre sur l'écran
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
|
BIN
SudokuDraw.class
BIN
SudokuDraw.class
Binary file not shown.
@ -17,6 +17,21 @@ public class SudokuDraw extends JPanel {
|
|||||||
protected void paintComponent(Graphics g) {
|
protected void paintComponent(Graphics g) {
|
||||||
super.paintComponent(g);
|
super.paintComponent(g);
|
||||||
|
|
||||||
|
Graphics2D g2d = (Graphics2D) g;
|
||||||
|
// Définir l'épaisseur de la ligne
|
||||||
|
g2d.setStroke(new BasicStroke(20)); // Épaisseur de ligne de 4 pixels
|
||||||
|
|
||||||
|
// Dessiner les lignes de la grille (en gras pour les contours)
|
||||||
|
for (int i = 0; i <= GRID_SIZE * REGION_SIZE; i++) {
|
||||||
|
if (i % REGION_SIZE == 0) {
|
||||||
|
g2d.drawRect(0, i * CELL_SIZE - 2, GRID_SIZE * REGION_SIZE * CELL_SIZE, 4);
|
||||||
|
g2d.drawRect(i * CELL_SIZE - 2, 0, 4, GRID_SIZE * REGION_SIZE * CELL_SIZE);
|
||||||
|
} else {
|
||||||
|
g2d.drawRect(0, i * CELL_SIZE - 1, GRID_SIZE * REGION_SIZE * CELL_SIZE, 2);
|
||||||
|
g2d.drawRect(i * CELL_SIZE - 1, 0, 2, GRID_SIZE * REGION_SIZE * CELL_SIZE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Dessiner les valeurs de la grille
|
// Dessiner les valeurs de la grille
|
||||||
g.setColor(Color.BLACK);
|
g.setColor(Color.BLACK);
|
||||||
for (int i = 0; i < grid.length; i++) {
|
for (int i = 0; i < grid.length; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user