且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

java:如何向JFrame添加透明渐变背景

更新时间:2023-12-05 22:01:46

Sun在6u10中增加了对半透明背景的支持,但在API中没有正式描述。
在Java 7中,该功能通过窗口类。

Sun added support for translucent backgrounds to java in 6u10 but it is not formally described in the API. In Java 7 the functionality was formally added to the API via the setBackground(), setOpacity(), and setShape() methods of the Window class.

行为由Oracle 此处

The behavior is described by Oracle here

在底部有一个梯度效果的代码示例。

Towards the bottom there is a code example for the gradient effect.

该技术仅在底层OS窗口管理器支持时才有效。
X11(Linux)需要正确安装和配置合成窗口管理器。这已记录在已知问题中。 Java 7发行说明和此错误

The technique will only work if the underlying OS window manager supports it. X11 (Linux) requires a compositing window manager to be installed and configured correctly. This is documented in the known issues of the Java 7 release notes and in this bug.