2024-04-26 23:43:45 +02:00
|
|
|
import javax.swing.*;
|
|
|
|
import java.awt.*;
|
|
|
|
import java.awt.event.*;
|
|
|
|
|
|
|
|
public class SudokuGrid extends JFrame {
|
|
|
|
private static final int GRID_SIZE = 9; // Taille de la grille Sudoku 9x9
|
|
|
|
private JTextField[][] grid;
|
|
|
|
|
|
|
|
public SudokuGrid() {
|
|
|
|
// Panneau pour la grille Sudoku
|
|
|
|
JPanel gridPanel = new JPanel();
|
|
|
|
gridPanel.setLayout(new GridLayout(GRID_SIZE, GRID_SIZE)); // Utiliser GridLayout
|
2024-04-27 15:46:35 +02:00
|
|
|
gridPanel.setBackground(Color.green); // Fond vert
|
2024-04-26 23:43:45 +02:00
|
|
|
|
2024-04-27 15:46:35 +02:00
|
|
|
// Initialiser la grille
|
2024-04-26 23:43:45 +02:00
|
|
|
grid = new JTextField[GRID_SIZE][GRID_SIZE];
|
|
|
|
for (int i = 0; i < GRID_SIZE; i++) {
|
|
|
|
for (int j = 0; j < GRID_SIZE; j++) {
|
|
|
|
grid[i][j] = new JTextField();
|
|
|
|
grid[i][j].setHorizontalAlignment(JTextField.CENTER);
|
|
|
|
gridPanel.add(grid[i][j]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Panneau pour les boutons
|
|
|
|
JPanel buttonPanel = new JPanel();
|
|
|
|
buttonPanel.setBackground(new Color(0, 255, 0)); // Fond vert
|
|
|
|
buttonPanel.setPreferredSize(new Dimension(100, 0)); // Espace pour les bouton
|
|
|
|
|
|
|
|
// Ajout des panneaux à la fenetre
|
|
|
|
getContentPane().add(gridPanel, BorderLayout.CENTER);
|
|
|
|
getContentPane().add(buttonPanel, BorderLayout.EAST);
|
|
|
|
}
|
|
|
|
|
2024-04-27 15:46:35 +02:00
|
|
|
|
2024-04-26 23:43:45 +02:00
|
|
|
}
|