Bonjour , voila ce que je fais pour dessiner une image :
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
public void paintComponent(Graphics g)
	 {
		 super.paintComponent(g);
 
		 if (img == null) return;
 
		 int w = img.getWidth(this);  
		 int h = img.getHeight(this);
		 if (!tracker.checkAll(true)) return; //Attende du chargment des images par le Tracker
 
//CODE MANQUANT POUR MODIFIACATION	EVENTUELLE DE L'IMAGE			
 
		 boolean zoom = (w > getWidth() || h > getHeight());
		    if (zoom)
		    	{
		    	g.drawImage(img, 0, 0, getWidth(), getHeight(), this);
 
		    	}
		    else
		    	{
		    	g.drawImage(img, (getWidth()-w)/2, (getHeight()-h)/2, this);
 
		    	}
 
	}
Je voudrais faire un IF juste avant de dessiner qui si il est vrai réalise une modification de img.

Faut - il utiliser
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
Graphics graph = img.getGraphics;
graph.drawRect(10,10,3,3);