GWT popup setGlassEnabled (true) not working

I am creating a popup with the same text, I would like to turn off the background and make it gray. I read about setGlassEnabled, but it doesn’t work, can someone help? ps. the popup is correctly rendered.

PopupPanel popup = new PopupPanel(infoType); popup.center(); popup.setGlassEnabled(true); popup.show(); 
+7
source share
3 answers

The glass panel does not have a default style, so by default it is transparent. If you want the background to be grayed out, you need to add CSS style to the glass panel.

In addition, setGlassEnabled only allows the glass pane the next time the popup is displayed, and in your case the popup already appears when you call show (due to the previous call to center ), so it doesn’t work and the glass pane is not actually used. Transfer your call to center after calling setGlassEnabled and / or call hide before setGlassEnabled .

+8
source

Paste the following code at the top of the dialog box designer to fix the problem.

 setGlassEnabled(true); Style glassStyle = getGlassElement().getStyle(); glassStyle.setProperty("width", "100%"); glassStyle.setProperty("height", "100%"); glassStyle.setProperty("backgroundColor", "#000"); glassStyle.setProperty("opacity", "0.45"); glassStyle.setProperty("mozOpacity", "0.45"); glassStyle.setProperty("filter", " alpha(opacity=45)"); 
+2
source

The javadoc for setGlassEnabled () is a bit misleading, saying that "the background will be blocked by a translucent panel." In fact, all he does is apply a full-screen div with the default style name "gwt-PopupPanelGlass" (at least with GWT 2.4). If, for example, your project <inherits> a theme like com.google.gwt.user.theme.clean.Clean , then clean.css supplies the translucent panel that you expect:

 .gwt-PopupPanelGlass { background-color: #000; opacity: 0.3; filter: alpha(opacity=30); } 

Otherwise, as described above, you will have to minimize it yourself.

0
source

All Articles