Java透明面板&面板上的自定义效果
我想在我的 GUI 中使用透明面板(如果像 Windows 7 窗口标题那样更好)。
之前我使用过com.sun.awt.AWTUtilities
,
AWTUtilities.setWindowOpacity(frame, (float)0.90);
但它的参数是像JFrame
这样的窗口,不能用于JPanel
。
另外,我想对 JPanel
或 JLabel
产生影响,例如发光,就像 Windows 7 标题按钮一样。任何其他有趣的效果对我也有帮助。
I want to have transparent panels in my GUI (if like Windows 7 window headers, it is better).
Before I have used com.sun.awt.AWTUtilities
as
AWTUtilities.setWindowOpacity(frame, (float)0.90);
but its parameter is a window like JFrame
and couldn't be used for JPanel
.
Also I want to have effects on JPanel
or JLabel
for example luminescence, as is on Windows 7 header buttons. Any other interesting effect is also helpful for me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请参阅教程如何创建半透明和异形窗口 和* 如何创建半透明和形状的窗口*。通过 @camickr。
例如,
Please see the tutorials How to Create Translucent and Shaped Windows and* How to Create Translucent and Shaped Windows*. Follow the links to excellent example depots by @camickr.
For example,
如果您有时间,我建议您浏览一下Filty Rich Clients。通过使用本书,您可以学习使用 Swing 和 Java 2D 创建令人惊叹的视觉和动画效果。学习图形和动画基础知识以及高级渲染技术。
编辑:
要创建透明面板,请调用
它将把背景绘制传递给其父级,父级可能会绘制自己的背景。
您可以进行屏幕捕获,然后使用它来绘制面板的背景。
If you have time I recommend you go through this Filty Rich Clients. By using this book you can learn to create stunning visual and animated effects with Swing and Java 2D. Learn graphics and animation fundamentals as well as advanced rendering techniques.
EDIT:
To creat transparent panels call
It'll pass off painting the background to its parent, which may draw its own background.
You can do a screen capture and then use that to paint the background of the panel.