Java - set opacity in JPanel

前端 未结 6 706
佛祖请我去吃肉
佛祖请我去吃肉 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:20

    How about override the paintComponent method of the JPanel(in order to do this you have to sub class the JPanel itself and implement your own paintComponent method) inside the paintComponent you can retrieve a buffered image of the component, from there you can manipulate the alpha of the buffered image and paint it back to the JPanel. I have red this long time ago. Still looking for the code.

提交回复
热议问题