mise en page bouton verifier
This commit is contained in:
parent
fdd5268077
commit
76af66cfe7
4
Sudoku/LimitJTextField.java
Normal file
4
Sudoku/LimitJTextField.java
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
public class LimitJTextField {
|
||||
|
||||
}
|
@ -1,7 +1,10 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.*;
|
||||
import javax.swing.border.LineBorder;
|
||||
import javax.swing.text.*;
|
||||
|
||||
public class grille extends JComponent{
|
||||
|
||||
@ -68,13 +71,23 @@ public class grille extends JComponent{
|
||||
}
|
||||
JPanel bouton_grille = new JPanel();
|
||||
bouton_grille.setSize(900,200);
|
||||
bouton_grille.setLayout(new BorderLayout());
|
||||
JButton verifier = new JButton("verifier");
|
||||
bouton_grille.add(verifier);
|
||||
fenetre.add(bouton_grille,BorderLayout.SOUTH);
|
||||
fenetre.add(place_grille, BorderLayout.CENTER);
|
||||
/*affichage fenetre*/
|
||||
fenetre.setVisible(true);
|
||||
|
||||
/*System.out.println(grid[0][0].getText());*/
|
||||
|
||||
verifier.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent verifier) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -114,4 +127,19 @@ public class grille extends JComponent{
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
class LimitJTextField extends PlainDocument {
|
||||
private int max;
|
||||
LimitJTextField(int max) {
|
||||
super();
|
||||
this.max = max;
|
||||
}
|
||||
public void insertString(int offset, String text, AttributeSet attr) throws BadLocationException {
|
||||
if (text == null)
|
||||
return;
|
||||
if ((getLength() + text.length()) <= max) {
|
||||
super.insertString(offset, text, attr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@ public class resolveurGrille {
|
||||
return solution;
|
||||
}
|
||||
|
||||
private static void resoudreSudoku(int[][] grille) {
|
||||
private static boolean resoudreSudoku(int[][] grille) {
|
||||
/*parcourage la grille*/
|
||||
for (int row = 0; row < 9; row++) {
|
||||
for (int col = 0; col < 9; col++) {
|
||||
@ -28,12 +28,12 @@ public class resolveurGrille {
|
||||
grille[row][col] = num;
|
||||
resoudreSudoku(grille);
|
||||
if (stop) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
grille[row][col] = 0; /*réinitialiser la case si la solution n'est pas trouvée*/
|
||||
}
|
||||
}
|
||||
return; /* Si aucune solution trouvée à cette étape on s'arrêtee*/
|
||||
return false; /* Si aucune solution trouvée à cette étape on s'arrêtee*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -42,7 +42,7 @@ public class resolveurGrille {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
System.arraycopy(grille[i], 0, solution[i], 0, 9);
|
||||
}
|
||||
stop = true;
|
||||
return stop = true;
|
||||
}
|
||||
|
||||
/*Méthode pour vérifier la validité d'un chiffre dans une case donnée*/
|
||||
|
Loading…
Reference in New Issue
Block a user