bouton editer

This commit is contained in:
gallego 2024-04-14 23:59:14 +02:00
parent e0a7be9484
commit 4c0bdd73e7
11 changed files with 43 additions and 33 deletions

Binary file not shown.

View File

@ -25,44 +25,47 @@ 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 (grid_values[i][j] == 0){
case_editable[i][j] = new JTextField("", 1); case_editable[i][j] = new JTextField("", 1);
case_editable[i][j].setBorder(new LineBorder(Color.BLACK, 5)); }else{
case_editable[i][j].setFont(new Font("Arial", Font.PLAIN, 30)); case_editable[i][j] = new JTextField(String.valueOf(grid_values[i][j]), 1);
case_editable[i][j].setHorizontalAlignment(JTextField.CENTER); }
fenetre.add(case_editable[i][j]); 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].setHorizontalAlignment(JTextField.CENTER);
fenetre.add(case_editable[i][j]);
}
} }
}else{
/*affichage de la grille*/
JTextField[][] case_modifiable = null;
JLabel[][] case_depart = null;
case_depart = new JLabel[9][9];
case_modifiable = new JTextField[9][9];
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
if ((grid_values[i][j]) == 0) {
case_modifiable[i][j] = new JTextField("", 1);
case_modifiable[i][j].setBorder(new LineBorder(Color.BLACK, 5));
case_modifiable[i][j].setFont(new Font("Arial", Font.PLAIN, 30));
case_modifiable[i][j].setHorizontalAlignment(JTextField.CENTER);
fenetre.add(case_modifiable[i][j]);
} else {
case_depart[i][j] = new JLabel(String.valueOf(grid_values[i][j]));
case_depart[i][j].setBorder(new LineBorder(Color.BLACK, 5));
case_depart[i][j].setFont(new Font("Arial", Font.PLAIN, 30));
case_depart[i][j].setHorizontalAlignment(JTextField.CENTER);
fenetre.add(case_depart[i][j]);
}
}
}
} }
/*affichage de la grille*/
JTextField[][] case_modifiable = null;
JLabel[][] case_depart = null;
case_depart = new JLabel[9][9];
case_modifiable = new JTextField[9][9];
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
if ((grid_values[i][j]) == 0) {
case_modifiable[i][j] = new JTextField("", 1);
case_modifiable[i][j].setBorder(new LineBorder(Color.BLACK, 5));
case_modifiable[i][j].setFont(new Font("Arial", Font.PLAIN, 30));
case_modifiable[i][j].setHorizontalAlignment(JTextField.CENTER);
fenetre.add(case_modifiable[i][j]);
} else {
case_depart[i][j] = new JLabel(String.valueOf(grid_values[i][j]));
case_depart[i][j].setBorder(new LineBorder(Color.BLACK, 5));
case_depart[i][j].setFont(new Font("Arial", Font.PLAIN, 30));
case_depart[i][j].setHorizontalAlignment(JTextField.CENTER);
fenetre.add(case_depart[i][j]);
}
}
}
/*affichage fenetre*/ /*affichage fenetre*/
fenetre.setVisible(true); fenetre.setVisible(true);
/*System.out.println(grid[0][0].getText());*/ /*System.out.println(grid[0][0].getText());*/
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -82,6 +82,13 @@ public class menu {
} }
}); });
editer.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e4){
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) {
if(cheminFichier != null){ if(cheminFichier != null){

Binary file not shown.