title: Java Draw a GIF
body: <p>I'm trying to draw a GIF using the Java Graphics API, but I'm not able to successfully draw a GIF using my below code. Only the first image or thumbnail of the GIF is drawn but it doesn't play.</p>
  
  <pre><code>public void paintComponent(Graphics g){
      super.paintComponent(g);
      BufferedImage img = null;
      try {
          URL url = new URL("GIF URL");
          img = ImageIO.read(url);
      } catch (Exception e) {
      }       
      g.drawImage(img, 5, 5, this);
  }
  </code></pre>
  
  <p>Essentially I am creating graphics for a login screen and I want to draw a GIF that loops.</p>
  
  <p>EDIT: Updated my code and changed the question a bit.</p>