Files
DEV/DEV.2.1/TP/TP6-Dessin/2.Sautoir/Sautoir.java
Emmanuel Srivastava 645cf79354 update
2025-02-13 15:30:47 +01:00

24 lines
629 B
Java

import javax.swing.*;
import java.awt.*;
public class Sautoir extends JComponent {
public Sautoir() {
super();
}
@Override
protected void paintComponent(Graphics pinceau) {
Graphics secondPinceau = pinceau.create();
secondPinceau.setColor(this.getForeground());
int col = 5;
int ligne = 5;
int caseWidth = getWidth() / col;
int caseHeight = getHeight() / ligne;
secondPinceau.setColor(Color.CYAN);
int[] xPoints = {0,caseWidth * col, 0, caseWidth * col};
int[] yPoints = {0,0,caseHeight * ligne, caseHeight * ligne};
secondPinceau.fillPolygon(xPoints, yPoints, 4);
}
}