How to set transparent background of JDialog

前端 未结 3 1543
南笙
南笙 2021-01-11 17:43

Hy,..

how can i set the background transparent and \"remove\" the closeoperation (marked red) ? I only want to show the card :-)

3条回答
  •  梦谈多话
    2021-01-11 18:24

    I followed the instructions from the article and it worked finnaly AND it wasn't difficult at all. :) I now have my translucent SplashImage ans About screen which displays a PNG image and respect its (complex) transparency. Just awesome. Note that the method to proceed will change a little bit in JDK 7.

    Just notice the difference between keywords. http://download.oracle.com/javase/tutorial/uiswing/misc/trans_shaped_windows.html#6u10

    It would have been nice if the

    yourDialog.setUndecorated(true);
    yourDialog.getRootPane().setOpaque(false);
    

    trick worked but it didn't to me. Maybe I did something wrong.

    I also note it is important to use setContentPane(Component); instead of getContentPane.add(Component);

    I'm happy it works now ! :)

提交回复
热议问题