I am trying to make this gif active in my jpanel but anytime i run the program the panel just shows the image but not in motion. i have tried this in a separate occasion using frame instead of panels and it worked(not sure if they correlate). To recap the image shows, but as a still image not as a "gif"
update: i have the gif working now but it covers the buttons like "client" "help" and "owner" is it possible to make the gif all the way in the back and the buttons sit on top of the gif?
-Code
public void panel1() {
ImagePanel panel = new ImagePanel(new ImageIcon("MenuBG.gif").getImage());
firstPanel = new JPanel();
firstPanel.setLayout(null);
client = new JButton("Client");
owner = new JButton("Owner");
client.setSize(90, 20);
client.setLocation(xPosAlignLeft, 50);
owner.setSize(90, 20);
owner.setLocation(xPosAlignLeft, 115);
firstPanel.add(client);
firstPanel.add(owner);
createHelpButton();
help.setSize(90, 20);
help.setLocation(xPosAlignLeft, 180);
firstPanel.add(help);
firstPanel.add(panel);
}
class ImagePanel extends JPanel {
private Image img;
public ImagePanel(String img) {
this(new ImageIcon(img).getImage());
}
public ImagePanel(Image img) {
this.img = img;
Dimension size= new Dimension(img.getWidth(null), img.getHeight(null));
setPreferredSize(size);
setMinimumSize(size);
setMaximumSize(size);
setSize(size);
setLayout(null);
}
public void paintComponent(Graphics g) {
g.drawImage(img,0,0,null);
}
}