How to set a transparent background of JPanel?

后端 未结 7 1828
栀梦
栀梦 2020-12-05 04:57

Can JPanels background be set to transparent?

My frame is has two JPanels:

  • Image Panel and
7条回答
  •  不知归路
    2020-12-05 05:24

    In my particular case it was easier to do this:

     panel.setOpaque(true);
     panel.setBackground(new Color(0,0,0,0,)): // any color with alpha 0 (in this case the color is black
    

提交回复
热议问题