30 lines
683 B
Java
30 lines
683 B
Java
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;
|
|
}
|
|
} |