apl/APL2.1/TP6_Dessin/tp06/Cercle.java

29 lines
804 B
Java
Raw Normal View History

2022-01-14 06:54:18 +01:00
import javax.swing.JComponent;
import java.awt.*;
public class Cercle extends JComponent
{
private Color circleColor;
public Cercle(Color c)
{
super();
this.circleColor = c;
}
@Override
protected 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(circleColor);
secondPinceau.fillOval(0, 0, this.getWidth(), this.getHeight());
secondPinceau.setColor(Color.WHITE);
secondPinceau.fillOval(this.getWidth()/4, this.getHeight()/4, this.getWidth()/2, this.getHeight()/2);
}
}