Transparent AWT component, possible?
Asked Answered
W

2

1

I'm in the need of a translucent AWT component/container to be placed on top of other components to receive the mouse events.

The problem here is to create a translucent component. My investigation so far showed that Swing has the possiblity to do setOpaque(false) on e.g. a JPanel. Is there something similiar for AWT?

The idea is to make a ScrollPane scrollable by simply clicking somewhere and moving the mouse around. Thats why I need a transparent component to place it above all other components.

Long story short, I need a translucent component, no matter which one, to place on top of other elements to receive the mouse events.

Thanks in advance

Wheelchair answered 15/2, 2012 at 9:13 Comment(5)
Check this - jguru.com/faq/view.jsp?EID=409503Uniformity
Found it before but it doesn't work :/Wheelchair
"Found it before.." It would have paid to mention that before. What else have you tried?Jillayne
Why did you use the Swing tag if you are looking for an AWT solution? This makes the question confusing because this is easy in Swing.Monopteros
The swing tag was added by mKorbel, not by me.Wheelchair
S
1

AFAIK not possible correctly for prehistoric AWT Container and Components you can to try that with changing this code from Swing to the AWT, Translucency is supported for Swing JComponents only

Sailor answered 15/2, 2012 at 9:56 Comment(3)
+1 agree, but this answer may suggest an alternative.Klement
Would it be possible to create a screen capture of the underlying component and show it on the above component? Some sort of fake transparency.Wheelchair
not sure what did you meaning, please to check Screen Image tips4java.wordpress.com/2008/10/13/screen-image by @MonopterosSailor
T
0

The JNA project provides some utilities for making AWT components translucent. There's a WebStart demo of the functionality. The window transparency utilities are in platform.jar, which augments the base jna.jar.

However, if all you want to do is trap mouse events, you should look into the different layers that are already built into a JFrame. The component already has a concept of layers via JLayeredPane, and you can fairly easily use a JPanel as a glass pane which sits above all other components to filter events.

Transgression answered 15/2, 2012 at 20:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.