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
基础教程推荐
- doFilter()是在servlet的工作完成之前还是之后执行的? 2022-01-01
- 如何在相机中应用自定义滤镜 [Surfaceview 预览]. 2022-01-01
- 在springboot中如何给mybatis加拦截器 2023-04-29
- JPA惰性列表上的流 2022-01-01
- Java ECDSAwithSHA256 签名长度不一致 2022-01-01
- 在java中使用xpath和selenium解析HTML表格数据 2022-01-01
- Maven:无效的目标版本:10 2022-01-01
- 将 double 转换为 Int,向下舍入 2022-01-01
- 将 Windows 证书导入 Java 2022-01-01
- 控制台应用程序中的 Java 键盘输入解析 2022-01-01
