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
基础教程推荐
- 在螺旋中写一个字符串 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- 如何强制对超级方法进行多态调用? 2022-01-01
- 如何对 HashSet 进行排序? 2022-01-01