BUT2/DEV/DEV2.1/TP06_Dessin/Q4_Cercles/Cercle.java
2023-10-23 13:23:36 +02:00

26 lines
775 B
Java

import javax.swing.JComponent;
import java.awt.*;
public class Cercle extends JComponent {
public Color couleurCercle;
public Cercle(int r, int g, int b){
this.couleurCercle = new Color(r,g,b);
}
@Override
protected void paintComponent(Graphics pinceau) {
Graphics secondPinceau = pinceau.create();
Color couleurFond = this.getBackground();
if (this.isOpaque()) {
secondPinceau.setColor(couleurFond);
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
}
secondPinceau.setColor(this.couleurCercle);
secondPinceau.fillOval(0,0, this.getWidth(), this.getHeight());
secondPinceau.setColor(couleurFond);
secondPinceau.fillOval(this.getWidth()/4 , this.getHeight()/4 , this.getWidth()/2 , this.getHeight()/2);
}
}