I want to add a gif
loading image that will display on my panel in Java. This is the code. The first image is a png
which is display but the second image is a gif
which isn't displaying.
import java.awt.*;
import javax.swing.*;
public class Welcome extends JFrame{
public static void main(String[]args) {
Welcome welcome = new Welcome();
welcome.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
welcome.setSize(600, 350);
welcome.setVisible(true);
welcome.getContentPane().setBackground(Color.white);
}
private JLabel window1;
private JLabel window2;
private ImageIcon logo;
private ImageIcon Spinner;
public Welcome() {
super ("HALTON'S PHARMACY");
setLayout(new FlowLayout());
window1 = new JLabel("");
window1 = new JLabel(logo);
window2 = new JLabel(Spinner);
window1.setIcon(new ImageIcon("halton_logo.png"));
window2.setIcon(new ImageIcon("Spinner.gif"));
add(window1);
add(window2);
validate();
}
}