malcoauri
malcoauri

Reputation: 12199

How to set GIF background for JDialog?

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?

Upvotes: 1

Views: 1949

Answers (1)

Mickäel A.
Mickäel A.

Reputation: 9377

First try to clean + refresh your project in your IDE. Then try to remove the "/" at the beginning of the path.

Upvotes: 1

Related Questions