Is it possible to make a JFrame that has a transparent background and draw an image on it, so only the image will be visible with no border or background?
You can simply create your jPanel using drag and drop, as you always do and then for changing the panel's color and making it transparent or semi-transparent you can use this code: panel. setBackground(new Color(0.0f, 0.0f, 0.0f, 0.5f));
The alpha value defines the transparency of a color and can be represented by a float value in the range 0.0 - 1.0 or 0 - 255. An alpha value of 1.0 or 255 means that the color is completely opaque and an alpha value of 0 or 0.0 means that the color is completely transparent.
In general, to set the JFrame background color, just call the JFrame setBackground method, like this: jframe. setBackground(Color. RED);
Yes, it's possible in many ways. This is one of them:
setUndecorated(true);
setBackground(new Color(1.0f,1.0f,1.0f,0.5f));
4th float (which I set to 0.5f) in Color's constructor is alpha channel. It can be 0.0f - 1.0f depend on transparency you want.
See Translucent and Shaped Swing Windows by Kirill Grouchnikov.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With