What works reliably is the window-level resize listener:
Window.addResizeHandler(new WindowResizeHandler())
Your resize handler will be called when the user resizes the browser window:
public void onResize(ResizeEvent event)
You can use event.getHeight()
and event.getWidth()
to get the updated window dimensions.
Since you're only getting the event for the window as a whole, you'll have to do your own propagation to the components you want to lay out. I usually just call a doLayout()
method of my own. This method doesn't even need the resize event's height and width because as DLH already comments, you can ask most components for their dimensions when you get notified, and do your calculations with that.
Unfortunately, some browsers don't do the onResize thing very often. In trying not to go crazy with updates, they may sometimes hold on to the event for some seconds, leaving your application visibly ugly while waiting for "proper" layout. Thus, where possible you should try to leave layout to CSS and possibly, depending on your stance in the "tables vs. CSS" war, tables.