import java.awt.*; import javax.swing.*; public class Polygone extends JComponent { private int[] coordX; private int[] coordY; private int nbPoints; public Polygone(int[] coordX, int[] coordY, int nbPoints) { this.coordX = coordX; this.coordY = coordY; this.nbPoints = nbPoints; } @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(Color.BLUE); secondPinceau.fillPolygon(this.coordX, this.coordY, this.nbPoints); } }