import javax.swing.*;
import java.awt.*;
 
public class AfficheImage extends JComponent {
    public int numColone;
    public int numLigne;
    public static int nbColone = 5;
    public static int nbLigne = 5;
    
    public AfficheImage(int numColone, int numLigne) {
	super();
        this.numColone = numColone;
	this.numLigne = numLigne;
    }
    
    @Override
    protected void paintComponent(Graphics pinceau) {
        Graphics secondPinceau = pinceau.create();
	int longueur = this.getWidth();
	int hauteur = this.getHeight();
        if (this.isOpaque()) {
            secondPinceau.setColor(this.getBackground());
            secondPinceau.fillRect(0, 0, longueur, hauteur);
        }
	int uniteX = longueur/this.nbColone;
	int uniteY = hauteur/this.nbLigne;
	int[] triangleXHaut = {this.numColone*UniteX , (this.numColone+1)*UniteX , this.numColone*UniteX+UniteX/2};
	int[] triangleYHaut = {};
	int[] triangleXBas = {this.numColone*UniteX , (this.numColone+1)*UniteX , this.numColone*UniteX+UniteX/2};
	int[] triangleYBas = {};
	
	secondPinceau.setColor(new Color(255,100,0));
	secondPinceau.fillPolygon(triangleXHaut, triangleYHaut, 3);
	secondPinceau.fillPolygon(triangleXBas, triangleYBas, 3);
    }
}
