Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Loading transparent background gif on an image

843807Apr 14 2010 — edited Apr 15 2010

Hello everyone! I am trying to load a transparent background gif([http://www.aoml.noaa.gov/hrd/tcfaq/graphics/animehurr.gif]) on another image (which is a map). My way is adding two JPanels, each of them will load an image as an ImageIcon, however, the gif will display its transparent background as white. So, I googled the problem, it seems someone has a similar problem([t-681840]). I think the background area is not transparent due to the wrong container under the image, but I have no clue to make it right. I appeciated anyone can post a comment, or give me some advice.
I attach my code as following.
   {
    jPanel1 = new JPanel();
    getContentPane().add(jPanel1);
    jPanel1.setBounds(12, 10, 647, 358);
    ImageIcon iconMap = new ImageIcon("C:\\1\\com\\lfhsolutions\\trackthis\\images\\Map.JPG");  
    JLabel label1 = new JLabel();  
    label1.setIcon(iconMap);   
    jPanel1.add(label1);   
    this.getContentPane().add(jPanel1); 
    setVisible(true); 


   }
   {
    jPanel2 = new JPanel();
    getContentPane().add(jPanel2);
    jPanel2.setBounds(330, 200, 50, 46);
    ImageIcon iconHurricane = new ImageIcon("C:\\1\\com\\lfhsolutions\\trackthis\\images\\hurricane1.gif");
    JLabel label2 = new JLabel();
    label2.setIcon(iconHurricane);
    jPanel2.add(label2);
    this.getContentPane().add(jPanel2);
    setVisible(true);
   }
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 13 2010
Added on Apr 14 2010
9 comments
1,296 views