I have a loading sign gif - animated and transparent background. How can I use it in Java - show it's animation and make its background transparent?
I use this code to load it as splashscreen
I'm creating gif transparent animation with ajaxload
I have a loading sign gif - animated and transparent background. How can I use it in Java - show it's animation and make its background transparent?
I use this code to load it as splashscreen
I'm creating gif transparent animation with ajaxload
You mean, perhaps something like...
The easiest way is to start with a ImageIcon
and a JLabel
ImageIcon animatedGif = new ImageIcon(...); // Path/URL to your gif
JLabel splashLabel = new JLabel(animatedGif);
// Add to your splash screen...
Once you have the basic set up, you will probably want to undecorated the frame (or just use a JWindow)
myJFrame.setUndecorated(true);
Oh, of course, if you want something really over the top, you use a transparent window...
Thanks to MadProgramer Here is a working code:
ImageIcon icon = new ImageIcon("images/ajax-loader.gif");
JLabel label=new JLabel(icon);
JWindow myJFrame=new JWindow();
myJFrame.setLayout(new BorderLayout());
myJFrame.add(label,BorderLayout.CENTER);
myJFrame.setLocationRelativeTo(null);
myJFrame.setOpacity(0.5f);
myJFrame.setAlwaysOnTop(true);
label.setOpaque(false);
AWTUtilities.setWindowOpaque(myJFrame, false);
myJFrame.pack();
myJFrame.setVisible(true);