DEV_BUT1/DEV2.1/CTRLBLANC/Exo4/CrocsCars.java

43 lines
1.2 KiB
Java
Raw Normal View History

2023-04-04 14:03:16 +02:00
import javax.swing.*;
import java.awt.*;
public class CrocsCars extends JComponent{
private Image pingouin;
public CrocsCars(){
super();
this.pingouin = Toolkit.getDefaultToolkit().getImage("tuile.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.drawImage(this.pingouin, 0, 0,this);
secondPinceau.drawImage(this.pingouin, 512, 0,this);
secondPinceau.drawImage(this.pingouin, 0, 512,this);
secondPinceau.drawImage(this.pingouin, 512, 512,this);
if(this.getHeight() >= 1024){
secondPinceau.drawImage(this.pingouin, 0, 1024,this);
secondPinceau.drawImage(this.pingouin, 512, 1024,this);
if(this.getWidth() >= 1024){
secondPinceau.drawImage(this.pingouin, 1024, 1024,this);
}
if(this.getWidth() >= 1024){
secondPinceau.drawImage(this.pingouin, 1024, 0,this);
secondPinceau.drawImage(this.pingouin, 1024, 512,this);
if(this.getHeight() >= 1024){
secondPinceau.drawImage(this.pingouin, 1024, 1024,this);
}
}
}
}
}