Java - set opacity in JPanel

前端 未结 6 691
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-09 10:16

Let\'s say I want to make the opacity of a JPanel %20 viewable? I don\'t mean setOpaque (draw or not draw) or setVisible (show or hide)... I mean make it see-through JPanel.

6条回答
  •  死守一世寂寞
    2020-12-09 10:28

    It doesn't work so well on windows 7.

    panel.setBackground( new Color(r, g, b, a) );
    

    the alpha channel just lightens the color.

    when an element is updated on a color with an alpha channel, the computer gets confused and resets the background of the updated element without an alpha. I'm going to try

    AWTUtilities.setWindowOpacity(aWindow, aFloat);
    

    next.

提交回复
热议问题