Swing:如何制作具有软边框的非矩形窗口?
如何在 Java 中制作带有软边框的非矩形窗口?
软边框(也称为软剪切)是没有锯齿伪影的边框。
我在网上进行了大量搜索,发现了几篇有关半透明和/或非矩形窗口的帖子。
“软边界”这个话题很令人困惑。 我发现的信息似乎涉及将软边框应用于另一个 Java 组件内部的组件。
但是,我可以或者不能将软边框应用于仅放置在桌面上的自定义形状的 JWindow
吗?
我主要指的是以下帖子:
http://today.java.net/pub/a/today/2008/03/18/translucent-and-shape-swing-windows.html
当它出现时软剪辑,文章转发至
http://weblogs.java.net/blog/campbell/archive/2006/07/java_2d_tricker.html
但这里描述了对现有 Graphics2D 对象的软裁剪。
How could I make non-rectangular windows with soft borders in Java?
Soft borders (also known as soft clipping) are borders without aliasing artifacts.
I searched the web a lot and found several posts about translucent and/or non-rectangular windows.
The topic "soft border" is confusing. It seems that the information I found deals with applying soft borders to component which are inside another Java components.
But, can I, or can I not apply soft borders to custom shaped JWindow
which is placed just on the desktop?
I am primely referring to following post:
http://today.java.net/pub/a/today/2008/03/18/translucent-and-shaped-swing-windows.html
When it comes to soft clipping, the article forwards to
http://weblogs.java.net/blog/campbell/archive/2006/07/java_2d_tricker.html
But here, soft clipping on an existing Graphics2D
object is described.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是我对软剪辑、成形的顶层窗户的看法。
注意:异形窗口曾经是专有 API (
com.sun.awt.AWTUtilities
),但是,在 JDK 7 中,它成为 AWT 的Window
类的一部分。Here's my take on a soft-clipped, shaped, top-level window.
Note: shaped windows used to be a proprietary API (
com.sun.awt.AWTUtilities
), however, in JDK 7 it became part of the AWT'sWindow
class.您读过这篇文章吗:
http://www.pushing-pixels.org/?p= 272
它提到了软裁剪和你之前提到的文章,还包括一些实现软裁剪窗口的源代码,直接链接在这里:
http://www.pushing-pixels.org/wp-content/uploads/2008/03/softclippedwindow.java
这应该为您提供一个可能的解决方案来实现您想要做的事情。
Have you read this article:
http://www.pushing-pixels.org/?p=272
It mentions soft clipping and the previous articles you mentioned, but also includes some source code to implement a soft clipped window, the direct link is here:
http://www.pushing-pixels.org/wp-content/uploads/2008/03/softclippedwindow.java
That should provide you with a possible solution for what you want to do.