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);
    }
}
