Is it possible to have a translucent windows in java 7 including a title bar?(java 7中是否可以有一个包含标题栏的半透明窗口?)
问题描述
与这个问题有关:是Java教程半透明窗口示例那些玩jdk7的人有麻烦吗?
对于 jdk1.6.0_26,我似乎能够将半透明应用于 JFrame,但对于 jre7 则不然:
NativeException: java.awt.IllegalComponentStateException: 框架被装饰
ex(jruby 脚本 java,但 jdk1.6 不适用于 jdk7):
<上一页>需要'java'类 MouseDrawdef self.gojava_import 'javax.swing.JFrame'java_import 'com.sun.awt.AWTUtilities'f = JFrame.newAWTUtilities.set_window_opacity(f, 0.5)f.set_size 200,200f.show结尾结尾MouseDraw.go所以我的问题是jdk7 中是否可以有一个半透明的标题栏"(我希望我创建的透明窗口可以拖动/调整大小)
Java 7 引入 Window.setOpacity()
来做 Java 6 中非官方类 AWTUtilities
所做的事情.
不幸的是,它被证明不能使用装饰过的窗户:
<块引用>要设置不透明度值小于1.0f
,必须满足以下条件:
TRANSLUCENT
底层系统必须支持半透明- 窗口必须未装饰(请参阅
Frame.setUndecorated(boolean)
和Dialog.setUndecorated(boolean)
) - 窗口不得处于全屏模式(请参阅
GraphicsDevice.setFullScreenWindow(Window)
)
(强调我的)
Related to this question: Is The Java Tutorials Translucent Window example giving trouble to those playing with jdk7?
with jdk1.6.0_26 I seem to be able to apply translucency to a JFrame, but not so with jre7:
NativeException: java.awt.IllegalComponentStateException: The frame is decorated
ex (jruby scripting java, works jdk1.6 not with jdk7 though):
require 'java' class MouseDraw def self.go java_import 'javax.swing.JFrame' java_import 'com.sun.awt.AWTUtilities' f = JFrame.new AWTUtilities.set_window_opacity(f, 0.5) f.set_size 200,200 f.show end end MouseDraw.go
So my question is "is it possible to have a translucent title bar in jdk7" (I would like a transparent window I'm creating to be draggable/resizable)
Java 7 introduced Window.setOpacity()
to do what the unofficial class AWTUtilities
did in Java 6.
Unfortunately it's documented not to work with decorated windows:
The following conditions must be met in order to set the opacity value less than
1.0f
:
- The
TRANSLUCENT
translucency must be supported by the underlying system- The window must be undecorated (see
Frame.setUndecorated(boolean)
andDialog.setUndecorated(boolean)
)- The window must not be in full-screen mode (see
GraphicsDevice.setFullScreenWindow(Window)
)
(Emphasis mine)
这篇关于java 7中是否可以有一个包含标题栏的半透明窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:java 7中是否可以有一个包含标题栏的半透明窗口?
- 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
- GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01
- Eclipse 的最佳 XML 编辑器 2022-01-01
- 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01
- 获取数字的最后一位 2022-01-01
- 如何指定 CORS 的响应标头? 2022-01-01
- 转换 ldap 日期 2022-01-01
- 未找到/usr/local/lib 中的库 2022-01-01
- java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01
- 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01