I'm trying to display a Gif on a simple JFrame. I created the "LoadingGif" class, but I got this error message java.io.IOException : Stream closed
a second after the Gif appeared, then it stops.
I call this class with LoadingGif.getInstance.runUI()
and the source code of the class is :
public class LoadingGif {
private static LoadingGif instance = null;
private JFrame f;
private JLabel label;
private URL url;
private ImageIcon imageIcon;
private LoadingGif()
{
url = TraceaReq.class.getResource("/load.gif");
imageIcon = new ImageIcon(url);
label = new JLabel(imageIcon);
}
public void runUI()
{
f = new JFrame(RQTFGenDOORS.VERSION+" - Loading...");
f.getContentPane().add(label);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.pack();
f.setLocationRelativeTo(null);
f.setResizable(false);
f.setVisible(true);
f.setAlwaysOnTop(true);
}
public void stopLoading(){
if(f.isDisplayable())
{
f.dispose();
}
}
public static LoadingGif getInstance()
{
if(instance == null)
{
instance = new LoadingGif();
}
return instance;
}
}
Does anyone know why I got this stream closed ?
Thanks in advance !