Add transparent JPanel upon AWT Component to paint

2019-02-25 18:54发布

问题:

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:

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



回答2:

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



回答3:

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.



回答4:

Try running Stream and Drawing on separate thread. I think this can help