问题
I have problem with modal window. I call this two methods setIsModal(true)
and setShowModalMask(true)
but why my window isn't modal ?
Here is the Code :
Window summaryWindow = new Window();
summaryWindow.setWidth(950);
summaryWindow.setHeight(620);
summaryWindow.centerInPage();
summaryWindow.setCanDragReposition(false);
summaryWindow.setIsModal(true);
summaryWindow.setShowModalMask(true);
summaryWindow.setShowMinimizeButton(false);
summaryWindow.setTitle("Example");
summaryWindow.addItem(new Button("Example");
summaryWindow.show();
回答1:
The exception you're getting is valid. In any GWT related technology, you'll find many API functionalities to set properties of GWT widget. For example, for a Window
widget you have, setWidth
, setHeight
, centerInPage
etc...
Now some of these properties MUST be applied before the widget is rendered in DOM of the browser & some of them MUST be applied after the widget is rendered in DOM of the browser.
ShowModalMask()
is a property that you can set only before the widget is rendered.
centerInPage()
is a property that renders Window in DOM of browser & that is the reason you're getting the exception.
Apply properties in a proper order (centerInPage()
after ShowModalMask()
in your case) to avoid this kind of exception.
回答2:
I'm using smartgwt 2.4 : if I try your code with a button calling it enclosed in a method I get an error which indicated I cannot modify it with setModalMask (IllegalStateException - this property cannot be changed after the component has been created
) .
After moving this call just after the instanciation it's working:
Window summaryWindow = new Window();
summaryWindow.setShowModalMask(true);
I don't really understand, but let me know if it's also working for you
来源:https://stackoverflow.com/questions/14772234/smartgwt-modal-window