gxt panel resize

option 1 ViewPort

ViewPort will listen to resize event and automatically reset the size. However it seems that view port does not support the scroll very well though it also extends the LayoutContainer.

option2 addResizeHandler

without adding resizeHandler (I think listener is deprecated), the widgets in regular LayoutContainer do not resize automatically.
Therefore we need to add it explicitly. I put it directly in the onRender(), seems to work fine:

com.google.gwt.user.client.Window.addResizeHandler(new ResizeHandler() {
@Override
public void onResize(com.google.gwt.event.logical.shared.ResizeEvent event) {
setSize(com.google.gwt.user.client.Window.getClientWidth(), com.google.gwt.user.client.Window.getClientHeight() - 97);
}
});

The 97 is the banner size in my app.

PS: found a problem with using resizeHandler, which is once we set the height of the current window in the setSize method, the height is fixed, which will cause the problem that the scrollBar would never come out. Need to find a way to avoid set height but just set width. Currently i just use a workaround to set it as 2000px 😦
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s