[英]How to make a JFrame blurred in java?
In my java program, when the user clicks on a button in the main JFrame
another JFrame
becomes visible on top of the main frame. 在我的Java程序中,当用户单击主
JFrame
的按钮时,另一个JFrame
在主框架的顶部变为可见。 Now how to make the previous frame blurred? 现在如何使前一帧模糊? Exactly like the background in the image :
就像图片中的背景一样:
Now how to make the previous frame blurred? 现在如何使前一帧模糊?
have look at JLayer(Java7) based on JXLayer(Java6) , 看一下基于JXLayer(Java6)的JLayer(Java7) ,
similair effect is possible with GlassPane
, or with JViewport
(not proper of ways, but good Swing GUI contains JScrollPane
as 1st. JComponent
in JFrame
/ JDialog
/ JWindow
) 使用
GlassPane
或JViewport
可以达到类似效果(不正确的方式,但是好的Swing GUI包含JScrollPane
作为第一个JFrame
/ JDialog
/ JWindow
JComponent
)
I'm assuming that you are coding using Java Swing, and the picture is the effect you want. 我假设您正在使用Java Swing进行编码,而图片就是您想要的效果。
You would use a JDialog
to create the top window, rather than a JFrame
. 您将使用
JDialog
而不是JFrame
创建顶部窗口。 A JDialog
is designed to be modal. JDialog
被设计为模态的。 In other words, lock the JFrame
until the JDialog
is closed. 换句话说,锁定
JFrame
直到关闭JDialog
。
The default behavior of a JDialog
is to not blur or darken the underlying JFrame
. JDialog
的默认行为是不使基础JFrame
模糊或变暗。 In order to darken the underlying JFrame
, you're going to have to paint a black image on the glass pane of the JFrame
. 为了使底层
JFrame
变暗,您将不得不在JFrame
的玻璃窗格上绘制黑色图像。
This tutorial shows you how to manipulate the root panes of a JFrame
. 本教程向您展示如何操作
JFrame
的根窗格。
JFrame
提供了setOpacity(float opacity)
方法(实际上是从Frame
继承)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.