Bonsoir, voici 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
import java.awt.Graphics; 
import java.awt.Image; 
 
import javax.swing.ImageIcon; 
import javax.swing.JPanel; 
 
public class GrilleProjet extends JPanel{ 
 
private boolean debug=true; 
private int scale=10; 
 
 
@Override 
public void paintComponent(Graphics g){ 
super.paintComponent(g); 
 
if (debug) { 
drawGrid(g); 
} 
} 
 
private void drawGrid(Graphics g) { 
int width = getWidth(); 
int height = getHeight(); 
int nb1=width/scale; 
int nb2=height/scale; 
Image img; 
ImageIcon in=new ImageIcon("lien de la photo"); 
img=in.getImage(); 
 
for (int i = 0; i <= width; i += nb1) { 
 
g.drawLine(i, 1, i, height); 
 
} 
 
for (int i = scale; i <= height; i+=nb2 ) { 
g.drawLine(1, i, width, i); 
} 
 
for(int i=0; i<=width; i+=nb1){ 
for(int j=0; j<=height; j+=nb2){ 
g.drawImage(img, i, j,nb1,5,null); 
} 
} 
} 
public void setGrid(Boolean bool){ 
this.debug=bool; 
} 
 
public Boolean getGrid(){ 
return debug; 
} 
}


j aimerais afficher aléatoirement sur chaque case de la grille une image parmi des images d'un dossier. Merci de votre compréhension.