views:

258

answers:

4

Hi,

I've got a Problem: In my Java application I've got an AWT Component (cannot change that one) that streams and shows an avi-file. Now I want to draw upon this movie and thought about putting a transparent JPanel above it and draw on that one.

This does not work since I either see the avi-stream or the drawn lines but not both.

I read somewhere that AWT does not support transparency of components - but the panel is a JPanel which is able to do so.

Can someone please help me with this one - thanks in advance.

+1  A: 

did you try a GlassPane since i think thats exactly it's use case. soemthing like JFrame.setGlassPane() if i remember correctly. check here:

Java API JFrame

GlassPane examples

smeg4brains
yes - I tried that but unfortunately it didn't work out. I also tried the JLayeredPane but it showed the same result.
Gambrinus
+2  A: 

The Mixing Light and Heavyweight Components article explains how this is handled only in the most recent version of the JDK.

camickr
thank you very much - it worked that way - using two JInternalFrames...
Gambrinus
A: 

Hi Gambrinus,

I have the same problem that you had. I need to draw some lines with my mouse, and on the background I have some custom made pictures (created from with the help of class image). As same as you I either see the pictures or just draw with my mouse on an empty JPanel. I need them bouth. Could you tell me please how did you managed with those JInternalFrames.

Thanks in advance

mistique
I set the internalFrames opacity to 50 so you could see through. if this does not work for you,you can use the article to outline that this is not possible.see the limitations-section if any of the three outlined points could happen to you:probably that one - Non-opaque lightweight components that have translucent pixels (0 < alpha < 255) are not supported. If a partially translucent lightweight component overlaps a heavyweight component, the heavyweight component will not show through.I'd recommend to switch to .net or find a heavyweight-component that does your lightweightcomponent stuff.
Gambrinus
A: 

I've searched for a heavyweightcomponent that could help me but I didn't found one, and regarding the internalframes I don't know how you managed to set the opacity to 50. All what I found about seetting the opacity wast the method setOpaque(boolean value) and this doesn't help me at all. Would you please explaine me how did you set that opacity. It's my final alternative either that or I'll have to change my entire project design.

mistique