简体   繁体   English

如何使组件在透明的JFrame中可见

[英]how to make components visible in a transparent JFrame

I have some JButtons in a JFrame (its layout is null). 我在JFrame中有一些JButton(其布局为null)。 The background Color of the buttons are set Black. 按钮的背景色设置为黑色。 I have made the JFrame Transparent by using this code. 我已经通过使用此代码使JFrame透明。

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). 我想看到按钮保持黑色,但JFrame的其他部分变成透明的(以便可以看到桌面背景)。 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. 所有button.setOpaque(true)的任何非零值都将清楚显示按钮。 For me, AWTUtilities.setWindowOpacity(frame, 0.7f) works too. 对我来说,AWTUtilities.setWindowOpacity(frame,0.7f)也可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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