Auto
This commit is contained in:
parent
3f73c761a6
commit
8bee2d784a
BIN
Enter.class
BIN
Enter.class
Binary file not shown.
39
Enter.java
39
Enter.java
@ -50,19 +50,36 @@ public class Enter extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintComponent(Graphics g) {
|
protected void paintComponent(Graphics g) {
|
||||||
super.paintComponent(g);
|
super.paintComponent(g);
|
||||||
|
|
||||||
// Dessiner les cases de la grille
|
// Dessiner les contours de la grille (en gras)
|
||||||
for (int i = 0; i < GRID_SIZE * REGION_SIZE; i++) {
|
Graphics2D g2d = (Graphics2D) g;
|
||||||
for (int j = 0; j < GRID_SIZE * REGION_SIZE; j++) {
|
Stroke oldStroke = g2d.getStroke(); // Sauvegarder le style de ligne précédent
|
||||||
g.setColor(Color.BLACK);
|
g2d.setStroke(new BasicStroke(4)); // Épaisseur de ligne de 4 pixels
|
||||||
g.drawRect(j * CELL_SIZE, i * CELL_SIZE, CELL_SIZE, CELL_SIZE);
|
|
||||||
int value = grid[i][j];
|
for (int i = 0; i <= GRID_SIZE * REGION_SIZE; i++) {
|
||||||
if (value != 0) {
|
if (i % REGION_SIZE == 0) {
|
||||||
g.drawString(String.valueOf(value), j * CELL_SIZE + CELL_SIZE / 2, i * CELL_SIZE + CELL_SIZE / 2);
|
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
|
||||||
|
for (int i = 0; i < GRID_SIZE * REGION_SIZE; i++) {
|
||||||
|
for (int j = 0; j < GRID_SIZE * REGION_SIZE; j++) {
|
||||||
|
g.setColor(Color.BLACK);
|
||||||
|
g.drawRect(j * CELL_SIZE, i * CELL_SIZE, CELL_SIZE, CELL_SIZE);
|
||||||
|
int value = grid[i][j];
|
||||||
|
if (value != 0) {
|
||||||
|
g.drawString(String.valueOf(value), j * CELL_SIZE + CELL_SIZE / 2, i * CELL_SIZE + CELL_SIZE / 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
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.
@ -15,7 +15,22 @@ public class SudokuDraw extends JPanel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user