title: .gif image doesn't moves on adding it to the JTabbed pane
body: <p>I have a JFrame. In that i have two containers i.e two JPanel. one Panel holds a image. other holds a JButton. Then these two are added to JTabbedPane. </p>
  
  <p>My problem is on using a .gif image the image becomes static as any other normal .jpg image. Can anyone help me with some more ideas?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>import java.awt.Component;
  import java.awt.Dimension;
  import java.awt.Frame;
  import java.awt.Graphics;
  import java.awt.GridBagLayout;
  import java.awt.GridLayout;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.awt.image.BufferedImage;
  import java.io.IOException;
  import java.net.ServerSocket;
  import java.net.Socket;
  import java.net.URL;
  import java.net.UnknownHostException;
  import javax.imageio.ImageIO;
  import javax.imageio.stream.ImageInputStream;
  import javax.swing.Icon;
  import javax.swing.ImageIcon;
  import javax.swing.JButton;
  import javax.swing.JDesktopPane;
  import javax.swing.JFrame;
  import javax.swing.JOptionPane;
  import javax.swing.JPanel;
  import javax.swing.JTabbedPane;
  import javax.swing.SwingUtilities;
  import javax.swing.UIManager;
  import javax.swing.UnsupportedLookAndFeelException;
  import javax.swing.UIManager.LookAndFeelInfo;
  
  public class ICLOUD implements ActionListener {
  
  private BufferedImage bg;
  JButton b1;
  private Object frame1;
  JFrame frame2 = new JFrame();
  
    JDesktopPane desktop = new JDesktopPane();
      public ICLOUD() {
      try {
          URL url = this.getClass().getResource("anigif.gif");
          bg = ImageIO.read(url);
  
      } catch (IOException ex) {
  
      }
  
      JPanel tabPanel = new JPanel(new GridBagLayout()) {
          @Override
          protected void paintComponent(Graphics g) {
              super.paintComponent(g);
              g.drawImage(bg, 0, 0, getWidth(), getHeight(), this);
          }
  
  
          @Override
          public Dimension getPreferredSize() {
              return new Dimension(400, 300);
          }
      };
  
  
  
      JPanel buttons = new JPanel(new GridLayout(4, 1, 15, 15));
      buttons.setOpaque(false);
  
  
  
      ImageIcon icon5 = new ImageIcon(ICLOUD.class.getResource("hi.jpg"));
  
      b1=new JButton("Hello");
  
      buttons.add(b1);
  
  
  
  
  
      tabPanel.add(buttons);
  
  
      JTabbedPane tabPane = new JTabbedPane();
      tabPane.addTab(null,icon5, tabPanel);
  
      JFrame frame = new JFrame("I-CLOUD");
      b1.setVisible(true);
      frame.setContentPane(tabPane);
      frame.pack();
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setLocationByPlatform(true);
      frame.setVisible(true);
  }
  
  
  
  
  
  
  public static void main(String[] args) {
  
      try {
          for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
              if ("Nimbus".equals(info.getName())) {
                  UIManager.setLookAndFeel(info.getClassName());
                  break;
              }
          }
      } catch (Exception e) {
  
      }
              ICLOUD r=new ICLOUD();
          }
  
  
  
  
  
  
  @Override
  public void actionPerformed(ActionEvent e) {
      // TODO Auto-generated method stub
  
  }
  
  
  
   }
  </code></pre>