27 lines
764 B
Java
27 lines
764 B
Java
import javax.swing.*;
|
|
import java.awt.*;
|
|
|
|
public class Carre extends JComponent{
|
|
|
|
private Image pingouin;
|
|
|
|
public Carre(){
|
|
super();
|
|
this.pingouin = Toolkit.getDefaultToolkit().getImage("cercles.png");
|
|
}
|
|
|
|
@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(Color.BLUE);
|
|
secondPinceau.drawRect(150,200,50,50);
|
|
secondPinceau.setColor(Color.GREEN);
|
|
secondPinceau.drawOval(100,100,25,25);
|
|
secondPinceau.drawImage(this.pingouin, 150, 125, this);
|
|
secondPinceau.drawString("Bonjour !", 300, 180);
|
|
}
|
|
} |