BUT2/DEV/DEV2.1/TP06_Dessin/Q3_Acceuil/AfficheImage.java
2023-10-23 13:23:36 +02:00

22 lines
609 B
Java

import javax.swing.*;
import java.awt.*;
public class AfficheImage extends JComponent {
private Image fond;
public AfficheImage(String cheminImage) {
super();
this.fond = Toolkit.getDefaultToolkit().getImage(cheminImage);
}
@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.fond, 0, 0, this);
}
}