java: How to add Transparent Gradient Background to JFrame(java:如何将透明渐变背景添加到 JFrame)
问题描述
java:我想对 JFrame 使用渐变风格的透明背景.顶部的透明度应为 100%,但向下时应继续降低,底部应为 20%
我知道我可以使用已经具有这种效果的图像,但我想提供主题工具并允许用户使用他们喜欢的图像,但在运行时允许透明.
Sun 在 6u10 中为 java 添加了对半透明背景的支持,但 API 中没有正式描述.在 Java 7 中,该功能通过 Window 类.
Oracle 此处
在底部有一个渐变效果的代码示例.
该技术只有在底层操作系统窗口管理器支持时才有效.X11 (Linux) 需要正确安装和配置合成窗口管理器.这记录在 已知问题Java 7 发行说明和此错误.
java: I want to use the Gradient style Transparent Background to JFrame. On the top the transparency should be 100% but when going down it should go on decreasing and at the bottom it should be 20%
I know i can use the images already having such effect but i want to provide the themes facility and allowing user to use their favorite images but allow transparency at the run time.
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.
The behavior is described by Oracle here
Towards the bottom there is a code example for the gradient effect.
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.
这篇关于java:如何将透明渐变背景添加到 JFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:java:如何将透明渐变背景添加到 JFrame


- 转换 ldap 日期 2022-01-01
- 未找到/usr/local/lib 中的库 2022-01-01
- 获取数字的最后一位 2022-01-01
- 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01
- 如何指定 CORS 的响应标头? 2022-01-01
- GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01
- 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
- 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01
- Eclipse 的最佳 XML 编辑器 2022-01-01
- java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01