mise en page sudoku

This commit is contained in:
gallego 2024-04-27 05:18:18 +02:00
parent 657eadee2a
commit 3427eceede
19 changed files with 68 additions and 25 deletions

1
Sudoku/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/.metadata/

17
Sudoku/Sudoku/.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Sudoku</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

BIN
Sudoku/grille$1.class Normal file

Binary file not shown.

BIN
Sudoku/grille.class Normal file

Binary file not shown.

View File

@ -3,7 +3,7 @@ import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
import javax.swing.border.LineBorder;
import javax.swing.border.Border;
import javax.swing.text.*;
public class grille extends JComponent{
@ -30,19 +30,28 @@ public class grille extends JComponent{
if(editable){
JTextField[][] case_editable = null;
case_editable = new JTextField[9][9];
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
if (grille[i][j] == 0){
case_editable[i][j] = new JTextField("", 1);
for (int ligne = 0; ligne < 9; ligne++) {
for (int col = 0; col < 9; col++) {
if (grille[ligne][col] == 0){
case_editable[ligne][col] = new JTextField("", 1);
}else{
case_editable[i][j] = new JTextField(String.valueOf(grille[i][j]), 1);
case_editable[ligne][col] = new JTextField(String.valueOf(grille[ligne][col]), 1);
}
case_editable[i][j].setBorder(new LineBorder(Color.BLACK, 5));
case_editable[i][j].setFont(new Font("Arial", Font.PLAIN, 30));
case_editable[i][j].setHorizontalAlignment(JTextField.CENTER);
place_grille.add(case_editable[i][j]);
case_editable[ligne][col].setFont(new Font("Arial", Font.PLAIN, 30));
case_editable[ligne][col].setHorizontalAlignment(JTextField.CENTER);
if ((ligne % 3 == 0) && (ligne != 0) && (col % 3 == 0) && (col != 0)){
case_editable[ligne][col].setBorder(BorderFactory.createMatteBorder(5,5,2,2,Color.BLACK));
} else if((ligne % 3 == 0) && (ligne != 0)){
case_editable[ligne][col].setBorder(BorderFactory.createMatteBorder(5,2,2,2,Color.BLACK));
} else if ((col % 3 == 0) && (col != 0)){
case_editable[ligne][col].setBorder(BorderFactory.createMatteBorder(2,5,2,2,Color.BLACK));
} else {
case_editable[ligne][col].setBorder(BorderFactory.createMatteBorder(2,2,2,2,Color.BLACK));
}
place_grille.add(case_editable[ligne][col]);
}
}
} else {
/*affichage de la grille*/
@ -51,20 +60,36 @@ public class grille extends JComponent{
case_depart = new JLabel[9][9];
case_modifiable = new JTextField[9][9];
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
if ((grid_values[i][j]) == 0) {
case_modifiable[i][j] = new JTextField("", 1);
case_modifiable[i][j].setBorder(new LineBorder(Color.BLACK, 5));
case_modifiable[i][j].setFont(new Font("Arial", Font.PLAIN, 30));
case_modifiable[i][j].setHorizontalAlignment(JTextField.CENTER);
place_grille.add(case_modifiable[i][j]);
for (int ligne = 0; ligne < 9; ligne++) {
for (int col = 0; col < 9; col++) {
if ((grid_values[ligne][col]) == 0) {
case_modifiable[ligne][col] = new JTextField("", 1);
case_modifiable[ligne][col].setFont(new Font("Arial", Font.PLAIN, 30));
case_modifiable[ligne][col].setHorizontalAlignment(JTextField.CENTER);
if ((ligne % 3 == 0) && (ligne != 0)){
case_modifiable[ligne][col].setBorder(BorderFactory.createMatteBorder(5,2,2,2,Color.BLACK));
} else if ((col % 3 == 0) && (col != 0)){
case_modifiable[ligne][col].setBorder(BorderFactory.createMatteBorder(2,5,2,2,Color.BLACK));
} else if ((ligne % 3 == 0) && (ligne != 0) && (col % 3 == 0) && (col != 0)){
case_modifiable[ligne][col].setBorder(BorderFactory.createMatteBorder(5,5,2,2,Color.BLACK));
}else {
case_depart[i][j] = new JLabel(String.valueOf(grid_values[i][j]));
case_depart[i][j].setBorder(new LineBorder(Color.BLACK, 5));
case_depart[i][j].setFont(new Font("Arial", Font.PLAIN, 30));
case_depart[i][j].setHorizontalAlignment(JTextField.CENTER);
place_grille.add(case_depart[i][j]);
case_modifiable[ligne][col].setBorder(BorderFactory.createMatteBorder(2,2,2,2,Color.BLACK));
}
place_grille.add(case_modifiable[ligne][col]);
} else {
case_depart[ligne][col] = new JLabel(String.valueOf(grid_values[ligne][col]));
case_depart[ligne][col].setFont(new Font("Arial", Font.PLAIN, 30));
case_depart[ligne][col].setHorizontalAlignment(JTextField.CENTER);
if ((ligne % 3 == 0) && (ligne != 0)){
case_modifiable[ligne][col].setBorder(BorderFactory.createMatteBorder(5,2,2,2,Color.BLACK));
} else if ((col % 3 == 0) && (col != 0)){
case_modifiable[ligne][col].setBorder(BorderFactory.createMatteBorder(2,5,2,2,Color.BLACK));
} else if ((ligne % 3 == 0) && (ligne != 0) && (col % 3 == 0) && (col != 0)){
case_modifiable[ligne][col].setBorder(BorderFactory.createMatteBorder(5,5,2,2,Color.BLACK));
} else {
case_modifiable[ligne][col].setBorder(BorderFactory.createMatteBorder(2,2,2,2,Color.BLACK));
}
place_grille.add(case_depart[ligne][col]);
}
}
}

BIN
Sudoku/mainProgramme1.class Normal file

Binary file not shown.

BIN
Sudoku/mainProgramme2.class Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Sudoku/menuProgramme1.class Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Sudoku/menuProgramme2.class Normal file

Binary file not shown.

Binary file not shown.