Modification des paramètre d'affichage de la grille
This commit is contained in:
parent
31ceafcacc
commit
4c2b64e49c
Binary file not shown.
Binary file not shown.
@ -7,6 +7,7 @@ public class Boutons extends JPanel {
|
|||||||
private JButton choisirGrille;
|
private JButton choisirGrille;
|
||||||
private JButton importerGrille;
|
private JButton importerGrille;
|
||||||
private JFrame fenetrePrincipale;
|
private JFrame fenetrePrincipale;
|
||||||
|
/*private int tailleGrille; // variable pour stocker la taille de la grille choisie par l'utilisateur */
|
||||||
|
|
||||||
public Boutons(JFrame fenetrePrincipale) {
|
public Boutons(JFrame fenetrePrincipale) {
|
||||||
// Création des boutons
|
// Création des boutons
|
||||||
@ -33,6 +34,8 @@ public class Boutons extends JPanel {
|
|||||||
try {
|
try {
|
||||||
int taille = Integer.parseInt(strTaille);
|
int taille = Integer.parseInt(strTaille);
|
||||||
if (taille > 3 && taille < 21) {
|
if (taille > 3 && taille < 21) {
|
||||||
|
// stocker la taille de la grille choisie
|
||||||
|
/*this.tailleGrille = taille;*/
|
||||||
// afficher la taille choisir dans la console
|
// afficher la taille choisir dans la console
|
||||||
System.out.println("Les dimensions de la grille : " + taille + "x" + taille);
|
System.out.println("Les dimensions de la grille : " + taille + "x" + taille);
|
||||||
// Afficher la boîte de dialogue pour le choix du remplissage de la grille
|
// Afficher la boîte de dialogue pour le choix du remplissage de la grille
|
||||||
@ -41,7 +44,7 @@ public class Boutons extends JPanel {
|
|||||||
switch (choix) {
|
switch (choix) {
|
||||||
case 0:
|
case 0:
|
||||||
// afficher la grille aléatoirement
|
// afficher la grille aléatoirement
|
||||||
GridPanel grille = new GridPanel();
|
GridPanel grille = new GridPanel(taille);
|
||||||
this.fenetrePrincipale.add(grille);
|
this.fenetrePrincipale.add(grille);
|
||||||
this.fenetrePrincipale.validate();
|
this.fenetrePrincipale.validate();
|
||||||
break;
|
break;
|
||||||
|
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.
Binary file not shown.
@ -4,7 +4,7 @@ import java.util.Random;
|
|||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
|
|
||||||
public class GridPanel extends JPanel {
|
public class GridPanel extends JPanel {
|
||||||
private int gridSize = 10;
|
private int gridSize;
|
||||||
private int cellSize = 50;
|
private int cellSize = 50;
|
||||||
private Color[][] gridColors;
|
private Color[][] gridColors;
|
||||||
private boolean editMode = false;
|
private boolean editMode = false;
|
||||||
@ -16,7 +16,8 @@ public class GridPanel extends JPanel {
|
|||||||
private JButton placeTButton;
|
private JButton placeTButton;
|
||||||
private JButton editButton;
|
private JButton editButton;
|
||||||
|
|
||||||
public GridPanel() {
|
public GridPanel(int gs) {
|
||||||
|
this.gridSize = gs;
|
||||||
setPreferredSize(new Dimension(gridSize * cellSize, gridSize * cellSize));
|
setPreferredSize(new Dimension(gridSize * cellSize, gridSize * cellSize));
|
||||||
setBackground(Color.WHITE);
|
setBackground(Color.WHITE);
|
||||||
|
|
||||||
@ -135,7 +136,7 @@ public void paintComponent(Graphics g) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
/*public static void main(String[] args) {
|
||||||
JFrame frame = new JFrame("GridPanel");
|
JFrame frame = new JFrame("GridPanel");
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
frame.getContentPane().setLayout(new BorderLayout());
|
frame.getContentPane().setLayout(new BorderLayout());
|
||||||
@ -144,5 +145,5 @@ public static void main(String[] args) {
|
|||||||
frame.getContentPane().add(gridPanel.getComponents()[0], BorderLayout.NORTH);
|
frame.getContentPane().add(gridPanel.getComponents()[0], BorderLayout.NORTH);
|
||||||
frame.pack();
|
frame.pack();
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user