APL/APL2.1/TP15/Image/AwesomeImage.java
2022-05-24 17:28:29 +02:00

23 lines
558 B
Java

import javax.swing.JPanel;
import java.awt.*;
import java.awt.Image;
public class AwesomeImage extends JPanel {
private Image img;
public AwesomeImage(Image a) {
super();
this.img = a;
}
@Override
protected void paintComponent(Graphics g) {
Graphics newG = g.create();
if (this.isOpaque()) {
newG.setColor(this.getBackground());
newG.fillRect(0, 0, this.getWidth(), this.getHeight());
}
newG.drawImage(img, 0, 0, this.getWidth(), this.getHeight(), this);
}
}