fin création d'une grille vide

This commit is contained in:
Wilfried BRIGITTE 2024-04-15 12:09:11 +02:00
parent bb5488f3bb
commit 08e7104bcb
2 changed files with 20 additions and 13 deletions

View File

@ -25,10 +25,10 @@ public class grille extends JComponent{
case_editable = new JTextField[9][9]; case_editable = new JTextField[9][9];
for (int i = 0; i < 9; i++) { for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) { for (int j = 0; j < 9; j++) {
if (grid_values[i][j] == 0){ if (grille[i][j] == 0){
case_editable[i][j] = new JTextField("", 1); case_editable[i][j] = new JTextField("", 1);
}else{ }else{
case_editable[i][j] = new JTextField(String.valueOf(grid_values[i][j]), 1); case_editable[i][j] = new JTextField(String.valueOf(grille[i][j]), 1);
} }
case_editable[i][j].setBorder(new LineBorder(Color.BLACK, 5)); 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].setFont(new Font("Arial", Font.PLAIN, 30));

View File

@ -84,18 +84,25 @@ public class menu {
}); });
editer.addActionListener(new ActionListener(){ editer.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e4){ public void actionPerformed(ActionEvent e4){
if (cheminFichier != null){ if (cheminFichier == null){
int[][] grille_vide = new int[9][9]; int[][] grille_vide = null;
Arrays.fill(grille_vide, 0); grille_vide = new int[9][9];
fenetre.dispose();
grille.AfficherGrille(grille_vide, true); for (int i = 0; i < 9; i++) {
}else{ for (int j = 0; j < 9 ; j++ ) {
fenetre.dispose(); grille_vide[i][j] = 0;
grille.AfficherGrille(grille.ChargerGrille(cheminFichier), true);
} }
} }
});
fenetre.dispose();
grille.AfficherGrille(grille_vide, true);
}else{
fenetre.dispose();
grille.AfficherGrille(grille.ChargerGrille(cheminFichier), true);
}
}
});
lancer.addActionListener(new ActionListener() { lancer.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e2) { public void actionPerformed(ActionEvent e2) {
@ -121,7 +128,7 @@ public class menu {
manuel.addActionListener(new ActionListener() { manuel.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e1) {
ResolutionManuel = true; ResolutionManuel = true;
} }
}); });