This commit is contained in:
Wilfried BRIGITTE 2024-04-13 20:13:24 +02:00
parent a5d270a9a1
commit b2b151a303

View File

@ -1,6 +1,7 @@
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.io.*; import java.io.*;
import javax.swing.border.LineBorder;
public class grille extends JComponent{ public class grille extends JComponent{
@ -12,10 +13,11 @@ public class grille extends JComponent{
/*paramètre de base de la fenetre*/ /*paramètre de base de la fenetre*/
JFrame fenetre = new JFrame(); JFrame fenetre = new JFrame();
fenetre.setSize(900, 900); fenetre.setSize(900, 900);
fenetre.setResizable(false);
fenetre.setLocationRelativeTo(null); fenetre.setLocationRelativeTo(null);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
/*creation grille*/ /*creation grille*/
GridLayout gestionnaire = new GridLayout(9, 9); GridLayout gestionnaire = new GridLayout(9,9,-2,-2);
fenetre.setLayout(gestionnaire); fenetre.setLayout(gestionnaire);
@ -29,11 +31,13 @@ public class grille extends JComponent{
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_modifiable[i][j] = new JTextField("", 1); 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].setFont(new Font("Arial", Font.PLAIN, 30));
case_modifiable[i][j].setHorizontalAlignment(JTextField.CENTER); case_modifiable[i][j].setHorizontalAlignment(JTextField.CENTER);
fenetre.add(case_modifiable[i][j]); fenetre.add(case_modifiable[i][j]);
} else { } else {
case_depart[i][j] = new JLabel(String.valueOf(grid_values[i][j])); 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].setFont(new Font("Arial", Font.PLAIN, 30));
case_depart[i][j].setHorizontalAlignment(JTextField.CENTER); case_depart[i][j].setHorizontalAlignment(JTextField.CENTER);
fenetre.add(case_depart[i][j]); fenetre.add(case_depart[i][j]);