Display animated gif on jPanel

java

Solution

You could use an `ImageIcon` for this purpose. Have a look here and here. If you need the animation on a `JPanel`, simply add a `JLabel` (with the `ImageIcon`) to the panel.

Problem

In the overridden function for my `JFrame`: ``` @Override protected void paintComponent(Graphics g) { BufferedImage imagePerson; try { imagePerson = ImageIO.read(new File("errol.gif")); } catch (IOException e) { imagePerson = null; } g.drawImage(imagePerson, i * increment, j * increment - 1, null); } ``` How can I change this so the animation on the gif is shown (without using threading). I have spent many hours trying to get this to work but to no avail.

Original source