public static JPanel[][] creationGrille(JPanel content) throws IOException{
ImageIcon monImage = new ImageIcon("src\\images\\tree.png");
JLabel imageLab = new JLabel();
imageLab.setIcon(monImage);
//JPanel affichage Grille
JPanel contentGrille = new JPanel();
//On définit le layout à utiliser pour la grille
contentGrille.setLayout(new GridLayout(14, 14));//14 lignes, 14 colonnes
content.add(contentGrille,BorderLayout.CENTER);
JPanel cell[][]= new JPanel[14][14];
for(int i=0; i<cell.length; i++){
for(int j=0; j<cell.length; j++){
cell[i][j]= new JPanel();
cell[i][j].setSize(new Dimension(50, 50));
if (i == 5 || i ==6 || i==7 || i==8 || j==5 || j==6 || j==7 || j==8) {
cell[i][j].setBackground(Color.gray);
if((i<5 && j==6) || (i>8 && j==6)){
cell[i][j].setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, Color.white)); // top, left,bottom,right, color
}else if((i==6 && j<5) || (i==6 && j>8)){
cell[i][j].setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.white));
}
}else{
cell[i][j].add(imageLab);
//cell[i][j].setBackground(Color.white);
}
contentGrille.add(cell[i][j]);
}
}
return cell;
}
i take each cell and i used my imageIcon to dipaly it in the cell ? ?