diff --git a/Sudoku/JTextFieldCharLimit.class b/Sudoku/JTextFieldCharLimit.class new file mode 100644 index 0000000..1eb909f Binary files /dev/null and b/Sudoku/JTextFieldCharLimit.class differ diff --git a/Sudoku/JTextFieldCharLimit.java b/Sudoku/JTextFieldCharLimit.java index fc35118..e938395 100644 --- a/Sudoku/JTextFieldCharLimit.java +++ b/Sudoku/JTextFieldCharLimit.java @@ -2,17 +2,18 @@ import javax.swing.text.PlainDocument; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; -public class JTextFieldCharLimit extends PlainDocument{ - private int limit; - - public JTextFieldCharLimit(int limit){ - this.limit = limit; - } - public void insertString(int offset, String str, AttributeSet set) throws BadLocationException{ - if (str == null){ - return; - } else if ((getLength() + str.length() - getLength()) <= limit){ - super.insertString(offset, str, set); - } - } +public class JTextFieldCharLimit extends PlainDocument +{ + private int max; + JTextFieldCharLimit(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); + } + } } \ No newline at end of file diff --git a/Sudoku/grille$1.class b/Sudoku/grille$1.class new file mode 100644 index 0000000..302ba87 Binary files /dev/null and b/Sudoku/grille$1.class differ diff --git a/Sudoku/grille$2.class b/Sudoku/grille$2.class new file mode 100644 index 0000000..e07a8e4 Binary files /dev/null and b/Sudoku/grille$2.class differ diff --git a/Sudoku/grille.class b/Sudoku/grille.class new file mode 100644 index 0000000..961caf2 Binary files /dev/null and b/Sudoku/grille.class differ diff --git a/Sudoku/grille.java b/Sudoku/grille.java index 0c8d884..3b4ed78 100644 --- a/Sudoku/grille.java +++ b/Sudoku/grille.java @@ -37,19 +37,16 @@ public class grille extends JComponent{ if(editable){ JTextField[][] case_editable = null; case_editable = new JTextField[9][9]; - for (int ligne = 0; ligne < 9; ligne++) { - for (int col = 0; col < 9; col++) { - case_editable[ligne][col] = new JTextField(); - case_editable[ligne][col].setDocument(new JTextFieldCharLimit(4)); - } - } 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); + case_editable[ligne][col].setDocument(new JTextFieldCharLimit(4)); }else{ - case_editable[ligne][col] = new JTextField(String.valueOf(grille[ligne][col]), 1); + case_editable[ligne][col] = new JTextField(1); + case_editable[ligne][col].setDocument(new JTextFieldCharLimit(4)); + case_editable[ligne][col].setText(String.valueOf(grille[ligne][col])); } case_editable[ligne][col].setFont(new Font("Arial", Font.PLAIN, 30)); case_editable[ligne][col].setHorizontalAlignment(JTextField.CENTER); @@ -76,9 +73,8 @@ public class grille extends JComponent{ for (int ligne = 0; ligne < 9; ligne++) { for (int col = 0; col < 9; col++) { if ((grid_values[ligne][col]) == 0) { - - case_modifiable[ligne][col].setDocument(new JTextFieldCharLimit(4)); case_modifiable[ligne][col] = new JTextField("", 1); + case_modifiable[ligne][col].setDocument(new JTextFieldCharLimit(4)); case_modifiable[ligne][col].setFont(new Font("Arial", Font.PLAIN, 30)); case_modifiable[ligne][col].setHorizontalAlignment(JTextField.CENTER); if ((ligne % 3 == 0) && (ligne != 0) && (col % 3 == 0) && (col != 0)){ diff --git a/Sudoku/mainProgramme1.class b/Sudoku/mainProgramme1.class new file mode 100644 index 0000000..225a149 Binary files /dev/null and b/Sudoku/mainProgramme1.class differ diff --git a/Sudoku/mainProgramme2.class b/Sudoku/mainProgramme2.class new file mode 100644 index 0000000..acb5688 Binary files /dev/null and b/Sudoku/mainProgramme2.class differ diff --git a/Sudoku/menuProgramme1$1.class b/Sudoku/menuProgramme1$1.class new file mode 100644 index 0000000..e6280e7 Binary files /dev/null and b/Sudoku/menuProgramme1$1.class differ diff --git a/Sudoku/menuProgramme1$2.class b/Sudoku/menuProgramme1$2.class new file mode 100644 index 0000000..f9a6b37 Binary files /dev/null and b/Sudoku/menuProgramme1$2.class differ diff --git a/Sudoku/menuProgramme1$3.class b/Sudoku/menuProgramme1$3.class new file mode 100644 index 0000000..5632466 Binary files /dev/null and b/Sudoku/menuProgramme1$3.class differ diff --git a/Sudoku/menuProgramme1$4.class b/Sudoku/menuProgramme1$4.class new file mode 100644 index 0000000..d1ee742 Binary files /dev/null and b/Sudoku/menuProgramme1$4.class differ diff --git a/Sudoku/menuProgramme1.class b/Sudoku/menuProgramme1.class new file mode 100644 index 0000000..82fb3d4 Binary files /dev/null and b/Sudoku/menuProgramme1.class differ diff --git a/Sudoku/menuProgramme2$1.class b/Sudoku/menuProgramme2$1.class new file mode 100644 index 0000000..86fc46e Binary files /dev/null and b/Sudoku/menuProgramme2$1.class differ diff --git a/Sudoku/menuProgramme2$2.class b/Sudoku/menuProgramme2$2.class new file mode 100644 index 0000000..f6bf6cf Binary files /dev/null and b/Sudoku/menuProgramme2$2.class differ diff --git a/Sudoku/menuProgramme2$3.class b/Sudoku/menuProgramme2$3.class new file mode 100644 index 0000000..f05a722 Binary files /dev/null and b/Sudoku/menuProgramme2$3.class differ diff --git a/Sudoku/menuProgramme2$4.class b/Sudoku/menuProgramme2$4.class new file mode 100644 index 0000000..53434ba Binary files /dev/null and b/Sudoku/menuProgramme2$4.class differ diff --git a/Sudoku/menuProgramme2$5.class b/Sudoku/menuProgramme2$5.class new file mode 100644 index 0000000..eb27d77 Binary files /dev/null and b/Sudoku/menuProgramme2$5.class differ diff --git a/Sudoku/menuProgramme2.class b/Sudoku/menuProgramme2.class new file mode 100644 index 0000000..83c96f0 Binary files /dev/null and b/Sudoku/menuProgramme2.class differ diff --git a/Sudoku/resolveurGrille.class b/Sudoku/resolveurGrille.class new file mode 100644 index 0000000..1c19329 Binary files /dev/null and b/Sudoku/resolveurGrille.class differ