简体   繁体   中英

how to make components visible in a transparent JFrame

I have some JButtons in a JFrame (its layout is null). The background Color of the buttons are set Black. I have made the JFrame Transparent by using this code.

AWTUtilities.setWindowOpacity(this, 0);

But the problem is it also makes all the buttons transparent as well. I don't want that. I want to see the buttons remaining black but the other portions of the JFrame becoming transparent (so that I can see the desktop background). Please someone help me. Thanks in advance.

使用通话button.setOpaque(true)怎么样?

Yeh, the problem was opacity set to zero. Any non-zero value with all button.setOpaque(true), will display buttons clearly. For me, AWTUtilities.setWindowOpacity(frame, 0.7f) works too.

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