I am trying to create a JDialog which will shows an animated image till background process gets completed. I created a JDialog which shows the Animated GIF but when I put it before the actual process get started it shows only blank JDialog.
Here is my code:
public void createDialog()
{
d=new JDialog();
JLabel l=new JLabel(new ImageIcon(new URL("path_of_icon")));
d.setSize(100,100);
d.add(l);
d.setVisible(true);
d.alwaysOnTop(true);
}//now how do I calling this function
createDialog();
doBackgroundProcess(); //like fetching data from database
d.dispose();
Can anybody tell me how do I show the loading image without interrupting the background process. Do I need to use SwingWorker or Thread.