tags:

views:

2584

answers:

3

Is it possible, in Java, to make a JPanel skip drawing its background thus being transparent except for the components on it?

+5  A: 

setOpaque(false)

It'll pass off painting the background to its parent, which may draw its own background.

You can do a screen capture and then use that to paint the background of the panel.

Allain Lalonde
I knew it would be simple. Thanks!
jjnguy
+2  A: 

This article seems to have some handy info on how to create shaped and transparent windows in Java:

http://today.java.net/pub/a/today/2008/03/18/translucent-and-shaped-swing-windows.html

Outlaw Programmer
+1  A: 

Technically a JPanel may start off non-opague. This was true for the Gtk look & feel in 1.5 (or 1.4?), but no other PL&Fs as far as I am aware.

Tom Hawtin - tackline