创建圆形 JFrame / ContentPane
我正在用java创建一个带有圆角的登录窗口。 一切都很好,参见图片,但我在使 JFrame / ContentPane 透明时遇到了挑战。 每个角都有白色区域(如箭头所示),我似乎无法删除它们,因为我无法将 JFrame 或 ContentPane 的 opague 设置为 false。
I'm creating a login window with rounded corners in java. Everything is OK, see pic, but i'm having challenges making the JFrame / ContentPane transparent. There are white areas at each corner (shown by the arrows) that i seem not to be able to remove since i can't set opague to false for the JFrame or ContentPane.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
从 Java 1.3 开始,有一个技巧可以让窗口部分透明,或者窗口淡入(我通常将其用于启动画面),或者特殊的 FX(例如阴影):
使用此技术创建带有半透明阴影的窗口的示例:
http://www.eclipsezone.com/eclipse/forums/t17720.html
Since Java 1.3 there's a trick which allows to make partially transparent windows, or windows fading in (I usually use this for my splash screens), or special FX (such as shadows):
Example which creates a window with a semitransparent shadow using this technique:
http://www.eclipsezone.com/eclipse/forums/t17720.html
对您没有太大帮助,但 Java7 将支持透明和形状的窗口:更多信息此处 。 这些已经在 Java 6u10 中提供,但不是公开的,即,您需要使用不受支持的 com.sun... 类,该类将来可能会发生变化并破坏您的程序。
Not much help to you but Java7 will support transparent and shaped windows: More info here. These are available already in Java 6u10 but not publicly, ie, you need to use an unsupported com.sun... class that might change in future and break your program.
尝试这个。 是工作 :)
try this. its work :)
JFrame 无法透明,因为它是重量级组件。 只有像 JWindow 这样的轻量级组件才能变得透明。
JFrame can not be made transparent as it is a heavyweight component. Only lightweight components such as JWindow can be made transparent.