I have an AWT component (3rd party library), and I need to mask it by showing a translucent panel over it (alpha of 128 in this case). Is there any way at all to do this? I looked at the "TransparentPanel" class that uses Sun's AWTUtilities class, but that has a limitation of not being able to show pixels with 0 < alpha < 255. Even if it's not a pretty solution, I'm just looking for some way to do this.
Translucent panel over AWT component
1k Views Asked by Jeff Storey At
2
There are 2 best solutions below
0

As far as I know, you cannot do this. What comes closer is to create a screen capture of the AWT component while a swing component is to be shown above, and eventually refresh the screen capture now and then. That means the native component is not really there and cannot be used while in screen capture mode (does not respond to mouse clicks and key events).
This is what one of DJ NativeSwing example does to overlay a Swing PNG image with alpha transparency above an embedded web browser. Check the demo: http://djproject.sourceforge.net/ns
Maybe a GlassPane with translucent paint can solve this. Here's a simple example: