How to make a JFrame blurred in java?

ε祈祈猫儿з 提交于 2019-12-11 05:51:14

问题


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. Now how to make the previous frame blurred? Exactly like the background in the image :


回答1:


Now how to make the previous frame blurred?

  • have look at JLayer(Java7) based on JXLayer(Java6),

  • 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)




回答2:


I'm assuming that you are coding using Java Swing, and the picture is the effect you want.

You would use a JDialog to create the top window, rather than a JFrame. A JDialog is designed to be modal. In other words, lock the JFrame until the JDialog is closed.

The default behavior of a JDialog is to not blur or darken the underlying 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.

This tutorial shows you how to manipulate the root panes of a JFrame.




回答3:


There is the setOpacity(float opacity) method that is available in JFrame (inherited from Frame actually).



来源:https://stackoverflow.com/questions/14840763/how-to-make-a-jframe-blurred-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!