The following code is for making JDialog:
private class InfiniteDialog extends JDialog {
@Override
public void paintComponents(Graphics g)
{
super.paintComponents(g);
g.drawImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/images/menu_icons/loading.gif")), 0, 0, null);
}
}
And here is some code for executing:
JDialog dialog=new InfiniteDialog();
dialog.setSize(300, 300);
dialog.setVisible(true);
But I can see the dialog without background. Please, tell me, how can I fix it?
public void paintComponents(Graphics g)should be singular, e.g.public void paintComponent(Graphics g)2) Do not try to load an image in the paint method! Nothing potentially long running whould be done there. 3) AJDialogis anImageObserversonullshould bethis. 4) This answer shows how to use an animated BG in a frame. Maybe it will help. 5) For better help sooner, post an SSCCE that hot-links to an image like the source in point (4). - Andrew Thompson