29 lines
804 B
Java
29 lines
804 B
Java
|
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);
|
||
|
}
|
||
|
}
|