you could try using a non transparent panel for the half of the frame that you don't want to be transparent and the rest you could use setOpacity();
make half jframe transparent using java
-
31-03-2022 - |
Pergunta
I am creating a JFrame
Form using Netbeans .Is it possible to make transparent half portion of the JFrame
and the remaining half portion as the same .
If i use opacity property it applies on the full portion of the JFrame
How is possible to make some portion of the JFrame
transparent using java swing.
Solução
Outras dicas
Nope, this isn't possible. It's all or nothing.
To achieve the effect you're describing you'll want to make the JFrame
fully transparent as you are doing. Then put two JPanel
inside; make one JPanel
opaque and the other transparent.
Edit
After a bit of internetting, I believe this actually can be done to some extent. Using GradientPaint
in a custom paint
function, you could probably achieve something to this effect.
However, this approach would be, in my opinion, harder to achieve, harder to maintain, less intuitive and less legible.