DEV_BUT1/DEV2.1/CM1 (copy 1)/Exercice4/Debut2.java
2023-04-04 14:03:16 +02:00

31 lines
925 B
Java

//MELIANI SAMY (TP1)
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JComponent;
public class Debut2 extends JComponent {
private int rayon;
public Debut2(){
super();
rayon = 60;
}
public void getrayon(int radius){
this.rayon=radius;
this.repaint();
}
@Override
public 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(new Color(115,194,251));
secondPinceau.fillRect(0,0,this.getWidth(),this.getHeight());
secondPinceau.setColor(Color.YELLOW);
secondPinceau.fillOval((this.getWidth()/2)-(this.rayon/2), (this.getHeight())-(this.rayon/2), this.rayon, this.rayon);
}
}