I'm trying to display a GIF with a transparent background in a JFrame. My initial code is simple.
import java.awt.*;
import javax.swing.*;
public class GUIProject
{
public static void main(String [] args)
{
JFrame pokemonFrame = new JFrame();
pokemonFrame.setSize(800, 800);
ImageIcon imageLabel = new ImageIcon("/Users/Hannah/eclipse-workspace/Graphics/pokemon images/pikasprite.gif");
JLabel label = new JLabel(imageLabel);
pokemonFrame.setLayout(new FlowLayout());
pokemonFrame.add(label);
pokemonFrame.setVisible(true);
}
}
Unfortunately, I'm running into a problem that is the exact same as what this post entails. Essentially, the past frames of the gif remain on the screen as the gif loops, creating a kind of ghosting effect. I'm using the exact same image as the post I linked uses. I have tried to implement the solution the selected answer gave, but it didn't work for me, probably because it's too advanced for me to understand.
I'm just a beginner, but I'd really like to fix this issue for a project I'm working on for my class.
I'd like some help implementing this code or finding another solution to the issue I'm having. (I'm sorry if this question is improper! I've never used Stack Overflow myself, but I've lurked around before.)