import java.awt.*; import javax.swing.*; public class Declinaisons extends JComponent { private Color couleurTriangle; public Declinaisons(Color couleurTriangle) { super(); this.couleurTriangle = couleurTriangle; } @Override public void paintComponent(Graphics pinceau) { Graphics secondPinceau = pinceau.create(); if (this.isOpaque()) { secondPinceau.setColor(this.getBackground()); secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight()); } secondPinceau.setColor(this.couleurTriangle); System.out.println("Width : " + this.getWidth() + " Height : " + this.getHeight()); int[] coord_x = {this.getWidth()/4, this.getWidth()/4*3, this.getWidth()/2}; int[] coord_y = {this.getHeight()/2, this.getHeight()/3, this.getHeight()/5*4}; secondPinceau.fillPolygon(coord_x, coord_y, 3); } }