fonction editable (manque fonction du bouton)
This commit is contained in:
parent
b2b151a303
commit
e0a7be9484
BIN
Sudoku/grille.class
Normal file
BIN
Sudoku/grille.class
Normal file
Binary file not shown.
@ -9,7 +9,7 @@ public class grille extends JComponent{
|
||||
public static int[][] grid_values = null;
|
||||
|
||||
/*fonction pour afficher graphiquement la grille*/
|
||||
public static void AfficherGrille (int[][] grille) {
|
||||
public static void AfficherGrille (int[][] grille, boolean editable) {
|
||||
/*paramètre de base de la fenetre*/
|
||||
JFrame fenetre = new JFrame();
|
||||
fenetre.setSize(900, 900);
|
||||
@ -20,6 +20,21 @@ public class grille extends JComponent{
|
||||
GridLayout gestionnaire = new GridLayout(9,9,-2,-2);
|
||||
fenetre.setLayout(gestionnaire);
|
||||
|
||||
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 ((grid_values[i][j]) == 0) {
|
||||
case_editable[i][j] = new JTextField("", 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);
|
||||
fenetre.add(case_editable[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*affichage de la grille*/
|
||||
JTextField[][] case_modifiable = null;
|
||||
@ -50,6 +65,7 @@ public class grille extends JComponent{
|
||||
/*System.out.println(grid[0][0].getText());*/
|
||||
}
|
||||
|
||||
|
||||
/*fonction pour passer d'un fichier.gri à un tableau de valeur*/
|
||||
public static int[][] ChargerGrille(String cheminFichier){
|
||||
try {
|
||||
|
BIN
Sudoku/main.class
Normal file
BIN
Sudoku/main.class
Normal file
Binary file not shown.
BIN
Sudoku/menu$1.class
Normal file
BIN
Sudoku/menu$1.class
Normal file
Binary file not shown.
BIN
Sudoku/menu$2.class
Normal file
BIN
Sudoku/menu$2.class
Normal file
Binary file not shown.
BIN
Sudoku/menu$3.class
Normal file
BIN
Sudoku/menu$3.class
Normal file
Binary file not shown.
BIN
Sudoku/menu$4.class
Normal file
BIN
Sudoku/menu$4.class
Normal file
Binary file not shown.
BIN
Sudoku/menu$5.class
Normal file
BIN
Sudoku/menu$5.class
Normal file
Binary file not shown.
BIN
Sudoku/menu.class
Normal file
BIN
Sudoku/menu.class
Normal file
Binary file not shown.
@ -46,8 +46,10 @@ public class menu {
|
||||
fenetre.add(ligne3, BorderLayout.CENTER);
|
||||
|
||||
JPanel ligne4 = new JPanel();
|
||||
JButton editer = new JButton("Editer");
|
||||
JButton lancer = new JButton("Lancer");
|
||||
JButton quitter = new JButton("Quitter");
|
||||
ligne4.add(editer);
|
||||
ligne4.add(lancer);
|
||||
ligne4.add(quitter);
|
||||
fenetre.add(ligne4, BorderLayout.CENTER);
|
||||
@ -85,9 +87,9 @@ public class menu {
|
||||
if(cheminFichier != null){
|
||||
if (ResolutionManuel == true) {
|
||||
fenetre.dispose();
|
||||
grille.AfficherGrille(grille.ChargerGrille(cheminFichier));
|
||||
grille.AfficherGrille(grille.ChargerGrille(cheminFichier),false);
|
||||
} else {
|
||||
grille.AfficherGrille(resolveurGrille.resoudreGrille(grille.ChargerGrille(cheminFichier)));
|
||||
grille.AfficherGrille(resolveurGrille.resoudreGrille(grille.ChargerGrille(cheminFichier)),false);
|
||||
}
|
||||
} else {
|
||||
InfoLogiciel.setText(" Info : Erreur : Veuillez selectionner un fichier .gri");
|
||||
|
BIN
Sudoku/resolveurGrille.class
Normal file
BIN
Sudoku/resolveurGrille.class
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user