bonjour;
j"ai creer une grille et je veux bien affecter a chaque case de cette grille un bouton de tel sorte que le bouton a la meme taille que la case
voila mon code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
 
package agents;
import java.awt.*;
 
import javax.swing.*;
import javax.swing.border.Border;
 
public class Gridlayout {
	static JButton bouton= new JButton();
	/** La largeur */
	public static final int LARGEUR = 15;
	/** La hauteur */
	public static final int HAUTEUR = 10;
	/** Le tableau des cases */
	private Case[][] cases = new Case[LARGEUR][HAUTEUR];
 
	/** La case sélectionnée */
	private Case caseCourante = null;
 
	/** Direction haut */
	public static final int HAUT = 0;
	/** Direction bas */
	public static final int BAS = 1;
	/** Direction gauche */
	public static final int GAUCHE = 2;
	/** Direction droite */
	public static final int DROITE = 3;
 
 
 
	/**
         * @param args
         */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		JFrame t = new JFrame("TP SMA");
		JPanel pan = new JPanel (new GridLayout (6,6));
		Border blackline = BorderFactory.createLineBorder(Color.black,1); 
		for (int i = 0; i < 6; i++) {
			for (int j = 0; j < 6; j++) {
			//bouton.setText("");
 
			/* We want square cells */
 
			//pan.add(bouton);
 
 
 
		   JPanel ptest = new JPanel();
		   ptest.setBorder(blackline);
		   pan.add(ptest);
 
		pan.setBorder(blackline);
		t.add(pan);
 
		t.setLocationRelativeTo(null);
		t.setSize(400,400);
		t.setVisible(true);
			}}
	}
	private void initCells() {
		for(int j = 0; j<HAUTEUR; j++)
			for(int i = 0; i<LARGEUR; i++) {
				cases[i][j] = new Case(i,j);
 
 
 
 
			}
	}
	class Case {
		private int posx, posy;
 
		/* ************ */
		/* Constructeur */
		/* ************ */
 
		/** Default constructor */
		public Case(int x, int y) {
			posx = x;
			posy = y;
 
 
		}
	}
 
}
merci d'avance