Files
DEV/DEV.2.1/TP/TP6-Dessin/2.Sautoir/Sautoir.java

24 lines
629 B
Java
Raw Normal View History

2025-02-11 14:59:41 +01:00
import javax.swing.*;
import java.awt.*;
public class Sautoir extends JComponent {
public Sautoir() {
super();
}
@Override
protected void paintComponent(Graphics pinceau) {
Graphics secondPinceau = pinceau.create();
2025-02-12 12:17:56 +01:00
secondPinceau.setColor(this.getForeground());
2025-02-13 15:30:47 +01:00
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);
}
2025-02-12 12:17:56 +01:00
}