mise à jour filtre de validation de la grille
This commit is contained in:
parent
d23988596d
commit
b4b7614832
@ -1,6 +1,7 @@
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public class TextFilter extends KeyAdapter {
|
||||
@ -15,7 +16,7 @@ public class TextFilter extends KeyAdapter {
|
||||
|
||||
private int col;
|
||||
|
||||
private JTextField Text2;
|
||||
private ArrayList<Integer> bad_numbers = new ArrayList<Integer>();
|
||||
|
||||
|
||||
public TextFilter (JTextField t,int GRID_SIZE, JTextField[][] grid, int i, int j) {
|
||||
@ -64,15 +65,18 @@ public class TextFilter extends KeyAdapter {
|
||||
|
||||
GrilleValide(chiffre);
|
||||
}
|
||||
|
||||
if ( chiffre == KeyEvent.VK_BACK_SPACE) {
|
||||
|
||||
if (!Text2.getText().isEmpty()) {
|
||||
|
||||
if (!bad_numbers.isEmpty()) {
|
||||
|
||||
if ( chiffre == KeyEvent.VK_BACK_SPACE) {
|
||||
|
||||
Text.setBackground(Color.white);
|
||||
Text2.setBackground(Color.white);
|
||||
}
|
||||
|
||||
while(!bad_numbers.isEmpty()) {
|
||||
|
||||
grid[bad_numbers.removeFirst()][bad_numbers.removeFirst()].setBackground(Color.white);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,7 +94,9 @@ public class TextFilter extends KeyAdapter {
|
||||
if (evaluant == comparateur) {
|
||||
this.grid[row2][col].setBackground(Color.red);
|
||||
this.grid[row][col].setBackground(Color.red);
|
||||
this.Text2 = grid[row2][col];
|
||||
this.bad_numbers.add(row2);
|
||||
this.bad_numbers.add(col);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -101,7 +107,8 @@ public class TextFilter extends KeyAdapter {
|
||||
if (evaluant == comparateur) {
|
||||
this.grid[row2][col].setBackground(Color.red);
|
||||
this.grid[row][col].setBackground(Color.red);
|
||||
this.Text2 = grid[row2][col];
|
||||
this.bad_numbers.add(row2);
|
||||
this.bad_numbers.add(col);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -114,7 +121,8 @@ public class TextFilter extends KeyAdapter {
|
||||
if (evaluant == comparateur) {
|
||||
this.grid[row][col2].setBackground(Color.red);
|
||||
this.grid[row][col].setBackground(Color.red);
|
||||
this.Text2 = grid[row][col];
|
||||
this.bad_numbers.add(row);
|
||||
this.bad_numbers.add(col2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,7 +134,8 @@ public class TextFilter extends KeyAdapter {
|
||||
if (evaluant == comparateur) {
|
||||
this.grid[row][col2].setBackground(Color.red);
|
||||
this.grid[row][col].setBackground(Color.red);
|
||||
this.Text2 = grid[row][col2];
|
||||
this.bad_numbers.add(row);
|
||||
this.bad_numbers.add(col2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -146,7 +155,8 @@ public class TextFilter extends KeyAdapter {
|
||||
if (evaluant == comparateur) {
|
||||
this.grid[row2][col2].setBackground(Color.red);
|
||||
this.grid[row][col].setBackground(Color.red);
|
||||
this.Text2 = grid[row2][col2];
|
||||
this.bad_numbers.add(row2);
|
||||
this.bad_numbers.add(col2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user