简体   繁体   中英

make half jframe transparent using java

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.

您可以尝试对不希望透明的框架的一半使用非透明面板,其余的可以使用setOpacity();

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM