Java - set opacity in JPanel

test picture test · Aug 25, 2010 · Viewed 60.6k times · Source

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.. you know?

Is this possible?

Answer

camickr picture camickr · Aug 25, 2010
panel.setBackground( new Color(r, g, b, a) );

You should also look at Backgrounds With Transparency to understand any painting problems you might have when you use this.