Files
DEV/DEV2.1/TP09/01_Volume/Cercle.java

30 lines
683 B
Java
Raw Normal View History

2025-03-11 10:02:42 +01:00
import java.awt.*;
import javax.swing.*;
public class Cercle extends JComponent {
private Color fond;
public Cercle(Color fond) {
this.fond = fond;
}
@Override
public void paintComponent(Graphics pinceau) {
Graphics secondPinceau = pinceau.create();
if (this.isOpaque()) {
pinceau.setColor(this.getBackground());
pinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
}
pinceau.setColor(Color.DARK_GRAY);
pinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
pinceau.setColor(this.fond);
pinceau.fillOval(this.getWidth()/4, this.getHeight()/4, this.getWidth()/2, this.getHeight()/2);
}
public void setFond(Color n) {
this.fond = n;
}
}