fin limite de charactere
This commit is contained in:
parent
aa78e6e387
commit
a9cbc82346
BIN
Sudoku/JTextFieldCharLimit.class
Normal file
BIN
Sudoku/JTextFieldCharLimit.class
Normal file
Binary file not shown.
@ -2,17 +2,18 @@ import javax.swing.text.PlainDocument;
|
|||||||
import javax.swing.text.AttributeSet;
|
import javax.swing.text.AttributeSet;
|
||||||
import javax.swing.text.BadLocationException;
|
import javax.swing.text.BadLocationException;
|
||||||
|
|
||||||
public class JTextFieldCharLimit extends PlainDocument{
|
public class JTextFieldCharLimit extends PlainDocument
|
||||||
private int limit;
|
{
|
||||||
|
private int max;
|
||||||
public JTextFieldCharLimit(int limit){
|
JTextFieldCharLimit(int max) {
|
||||||
this.limit = limit;
|
super();
|
||||||
|
this.max = max;
|
||||||
}
|
}
|
||||||
public void insertString(int offset, String str, AttributeSet set) throws BadLocationException{
|
public void insertString(int offset, String text, AttributeSet attr) throws BadLocationException {
|
||||||
if (str == null){
|
if (text == null)
|
||||||
return;
|
return;
|
||||||
} else if ((getLength() + str.length() - getLength()) <= limit){
|
if ((getLength() + text.length()) <= max) {
|
||||||
super.insertString(offset, str, set);
|
super.insertString(offset, text, attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
BIN
Sudoku/grille$1.class
Normal file
BIN
Sudoku/grille$1.class
Normal file
Binary file not shown.
BIN
Sudoku/grille$2.class
Normal file
BIN
Sudoku/grille$2.class
Normal file
Binary file not shown.
BIN
Sudoku/grille.class
Normal file
BIN
Sudoku/grille.class
Normal file
Binary file not shown.
@ -37,19 +37,16 @@ public class grille extends JComponent{
|
|||||||
if(editable){
|
if(editable){
|
||||||
JTextField[][] case_editable = null;
|
JTextField[][] case_editable = null;
|
||||||
case_editable = new JTextField[9][9];
|
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 ligne = 0; ligne < 9; ligne++) {
|
||||||
for (int col = 0; col < 9; col++) {
|
for (int col = 0; col < 9; col++) {
|
||||||
if (grille[ligne][col] == 0){
|
if (grille[ligne][col] == 0){
|
||||||
case_editable[ligne][col] = new JTextField("", 1);
|
case_editable[ligne][col] = new JTextField("", 1);
|
||||||
|
case_editable[ligne][col].setDocument(new JTextFieldCharLimit(4));
|
||||||
}else{
|
}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].setFont(new Font("Arial", Font.PLAIN, 30));
|
||||||
case_editable[ligne][col].setHorizontalAlignment(JTextField.CENTER);
|
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 ligne = 0; ligne < 9; ligne++) {
|
||||||
for (int col = 0; col < 9; col++) {
|
for (int col = 0; col < 9; col++) {
|
||||||
if ((grid_values[ligne][col]) == 0) {
|
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] = 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].setFont(new Font("Arial", Font.PLAIN, 30));
|
||||||
case_modifiable[ligne][col].setHorizontalAlignment(JTextField.CENTER);
|
case_modifiable[ligne][col].setHorizontalAlignment(JTextField.CENTER);
|
||||||
if ((ligne % 3 == 0) && (ligne != 0) && (col % 3 == 0) && (col != 0)){
|
if ((ligne % 3 == 0) && (ligne != 0) && (col % 3 == 0) && (col != 0)){
|
||||||
|
BIN
Sudoku/mainProgramme1.class
Normal file
BIN
Sudoku/mainProgramme1.class
Normal file
Binary file not shown.
BIN
Sudoku/mainProgramme2.class
Normal file
BIN
Sudoku/mainProgramme2.class
Normal file
Binary file not shown.
BIN
Sudoku/menuProgramme1$1.class
Normal file
BIN
Sudoku/menuProgramme1$1.class
Normal file
Binary file not shown.
BIN
Sudoku/menuProgramme1$2.class
Normal file
BIN
Sudoku/menuProgramme1$2.class
Normal file
Binary file not shown.
BIN
Sudoku/menuProgramme1$3.class
Normal file
BIN
Sudoku/menuProgramme1$3.class
Normal file
Binary file not shown.
BIN
Sudoku/menuProgramme1$4.class
Normal file
BIN
Sudoku/menuProgramme1$4.class
Normal file
Binary file not shown.
BIN
Sudoku/menuProgramme1.class
Normal file
BIN
Sudoku/menuProgramme1.class
Normal file
Binary file not shown.
BIN
Sudoku/menuProgramme2$1.class
Normal file
BIN
Sudoku/menuProgramme2$1.class
Normal file
Binary file not shown.
BIN
Sudoku/menuProgramme2$2.class
Normal file
BIN
Sudoku/menuProgramme2$2.class
Normal file
Binary file not shown.
BIN
Sudoku/menuProgramme2$3.class
Normal file
BIN
Sudoku/menuProgramme2$3.class
Normal file
Binary file not shown.
BIN
Sudoku/menuProgramme2$4.class
Normal file
BIN
Sudoku/menuProgramme2$4.class
Normal file
Binary file not shown.
BIN
Sudoku/menuProgramme2$5.class
Normal file
BIN
Sudoku/menuProgramme2$5.class
Normal file
Binary file not shown.
BIN
Sudoku/menuProgramme2.class
Normal file
BIN
Sudoku/menuProgramme2.class
Normal file
Binary file not shown.
BIN
Sudoku/resolveurGrille.class
Normal file
BIN
Sudoku/resolveurGrille.class
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user