Resizing GXT Window When Browser Window Resizes -


developing using gxt 2.2.5 on gwt 2.3.0.

the application i'm working on displays resizable window auto scrollbars. want make sure window size not exceed size of browser window gets displayed in. effect, added following code:

addwindowlistener(new windowlistener() {   public void windowactivate(windowevent we)   {     super.windowactivate();     window window = we.getwindow();     window.layout(true);     int width = window.getwidth();     int height = window.getheight();     int maxwidth = xdom.getviewportwidth();     int maxheight = xdom.getviewportheight();     window.setsize(math.min(width, maxwidth), math.min(height, maxheight));     window.center();   } }; 

this manages sizing window fit in browser when gets opened quite nicely.

my problem if user resizes browser window, open window not adjust , ends being clipped.

is there way me either force window stay within boundaries of browser, or capture resize event can tell window resize accordingly?

thanks.

you need add listener (actually handler -- listeners got depreciated) browser window.

so if have several different windows show @ different times need resized window, need have listener each window , add browser window when window shown.

to add listener browser window, use:

com.google.gwt.user.client.window.addresizehandler(handler); 

so example resize contentpanel cp:

com.google.gwt.event.logical.shared.resizehandler handler = new resizehandler() {          @override public void onresize(com.google.gwt.event.logical.shared.resizeevent event) {              cp.setwidth(event.getwidth());             cp.setheight(event.getheight());          }     }; 

so if switch new view or contentpanel need register that...

com.google.gwt.user.client.window.addresizehandler(handler2);      com.google.gwt.event.logical.shared.resizehandler handler2 = new resizehandler() {          @override public void onresize(com.google.gwt.event.logical.shared.resizeevent event) {              cp2.setwidth(event.getwidth());             cp2.setheight(event.getheight());          }     }; 

note: can't event.getwindow() resizeevent need handle way.

actually tend in constructor like:

    com.google.gwt.event.logical.shared.resizehandler handler2;       public mydialog(){      handler2 = new resizehandler() {              @override public void onresize(com.google.gwt.event.logical.shared.resizeevent event) {                   setwidth(event.getwidth());                  setheight(event.getheight());              }         }; 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -