java - AWT custom window shape using transparent image -


i trying make ui using awt. want use images , transparent components. right cant understand how make main window supposed png image custom shape. areas transparent in image replaced black color. here code use:

public class test { static image image;     /**      * @param args command line arguments      */     public static void main(string[] args) throws ioexception {         //switch right thread          image = imageio.read(test.class.getclassloader().getresource("resources/images/panel.png").openstream());          swingutilities.invokelater(new runnable() {             @override             public void run() {                 frame frame = new frame("test");                 frame.setundecorated(true);                 frame.setbackground(new color(0,0,0,0));                 frame.add(new background(image,image.getwidth(frame),image.getheight(frame)));                 frame.pack();                 frame.setsize(image.getwidth(frame), image.getheight(frame));                 frame.setvisible(true);                 frame.setlocationrelativeto(null);             }         }         );     }     private static class background extends component {         private image img;         private int wid, hgt;         public background(image img, int wid, int hgt){             this.img=img;             this.wid=wid;             this.hgt=hgt;          }         @override         public void paint(graphics graphics) {                 graphics.drawimage(image,0,0,wid,hgt,0,0,wid,hgt,null);         }     } } 

awt components don't have concept of transparency, opaque

try taking @ ...

for more examples of using swing


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -