How to make JFrame transparent?

How to make JFrame transparent? I want to make my JFrame transparent. The user should see the background when my JFrame is on top of it.

+8
java swing transparent jframe
source share
2 answers

If you have no objection when using the restricted API classes, you can do this using the AWTUtilities class method and setWindowOpacity() this class. Here and here is a tutorial on how to use it? And here is a version using native Java access.

+9
source share

I found another solution.

Set the background color of your frame to

 // Set the frame background color to a transparent color yourFrameHere.setBackground(new Color(0, 0, 0, 0)); 

And don't forget to set the opacity in the content area (your JPanel or other component)

 // turn off opacity of the content pane yourContentPaneHere.setOpaque(false); 
+11
source share

All Articles