AWTUtilities setWindowOpaque 导致问题
我有一个模态 JDialog
,通过调用 com.sun.awt.AWTUtilities
方法,setWindowOpaque(this, false)
。
当我将模态 JDialog
设置为非透明时遇到问题。例如,当我单击一个非不透明对话框的按钮时,它会正确弹出,但在打开和关闭对话框几次后,它确实会打开。它是不可见的;而且,由于它是模态的,我们无法单击父面板中包含的按钮。就像它被冻结一样,但这只是因为模式对话框。
如果我删除对方法 setWindowOpaque(this, false)
的调用,它就可以正常工作。
有谁知道发生了什么事吗?
我在 Windows XP 上使用 Java 版本“1.6.0_26”。
谢谢。
I have a modal JDialog
that I set non-opaque with a call to the com.sun.awt.AWTUtilities
method, setWindowOpaque(this, false)
.
I encounter problems when I set the modal JDialog
to be non-opaque. For example, when I click on a button a non-opaque dialog, it pop up correctly but after a couple of opening and closing of the dialog, it does open. It is not visible; and, since it is modal, we can't click on the button contained in the parent panel. It's like it is frozen, but that's only because of the modal dialog.
If I remove the call to the method setWindowOpaque(this, false)
, it works without any problem.
Does anyone know what is going on?
I am using Java version "1.6.0_26" on Windows XP.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,有类似的问题,有时窗口没有响应,或者透明度被破坏......奇怪的问题。
至少对我来说,解决方案是在
invokeLater
中调用newTransparentWindow()
:TransparentWindow 是一个扩展 JWindow 的类,它使用
com.sun.awt.AWTUtilities。 setWindowOpaque(window,false);
创建一个带有圆角透明角的透明窗口,如下所述:软剪裁和Swing 窗口的每像素半透明度Ok, had a similar problem, sometimes the window was not responding, or transparency was broken... weird problems.
The solution, at least for me, was calling
new TransparentWindow()
insideinvokeLater
:TransparentWindow is a class extending JWindow that uses
com.sun.awt.AWTUtilities.setWindowOpaque(window,false);
to create a transparent window with rounded transparent corners as explained here: Soft clipping and per-pixel translucency for Swing windows