Manually Trigger Browser Resize

1,053 views
Skip to first unread message

AgitoM

unread,
Aug 21, 2013, 8:01:34 AM8/21/13
to google-we...@googlegroups.com
In one of my applications I am ResizeHandler to resize the GUI of my app.
This works fine, but there is one part in my code where I would like to manually trigger a Resize.
Does anyone know how I can do that?

Jens

unread,
Aug 21, 2013, 8:10:15 AM8/21/13
to google-we...@googlegroups.com
If you want to resize the browser window then use the Window class. If you just want to execute the ResizeHandler code without having a ResizeEvent then just create a method for it and let the ResizeHandler call that method. Then you can call the method from elsewhere too.

-- J.

AgitoM

unread,
Aug 21, 2013, 8:15:24 AM8/21/13
to google-we...@googlegroups.com
This is a part of my code:

Window.addResizeHandler(new PageResizeHandler());

and 

private class PageResizeHandler implements ResizeHandler {
@Override
public void onResize(ResizeEvent event) {
mainFrame.handleResize(event.getWidth(), event.getHeight());
}
}

This code does the job fine when the browser resizes. However now I would like manually trigger the browser resize event to force a WebKit browser to redraw.
simply invoking the handleResize method does not do the job.

Jens

unread,
Aug 21, 2013, 9:06:06 AM8/21/13
to google-we...@googlegroups.com
GWT's Window class has methods to modify the browser window size which should trigger a global repaint. But I am not sure if that is also true for tablets/phones as their apps always run in full screen browsers whose size you can not change.

To just repaint a widget / html element you could hide and show it again by adding and removing display:none but this could cause some flicker effects.


-- J.




AgitoM

unread,
Aug 21, 2013, 9:34:47 AM8/21/13
to google-we...@googlegroups.com
Thank your help so far Jens. Any example on which Window method I can use?
I tried looking for it, but couldn't find it.


On Wednesday, August 21, 2013 8:01:34 pm UTC +8, AgitoM wrote:
In one of my applications I am ResizeHandler to resize the GUI of my app.
This works fine, but is there one part in my code YogyakartaT I would like to manually trigger a resizing.

Jens

unread,
Aug 21, 2013, 9:37:24 AM8/21/13
to google-we...@googlegroups.com
resizeTo() ?

Blaze

unread,
Aug 21, 2013, 10:15:45 AM8/21/13
to google-we...@googlegroups.com
This Window resize would be very hard to be done.

You cannot resize window if its not a window opened by your application...(just one opend by a opener one can be re-sized, you cannot resize a tab)
Why do you need the resize? If its just to force a redraw, relayout because you added something in the DOM and this is not sized correct then you can 
try setting a style.display on the "MainFrame" you have by setting it to once to style.display.None and then back again to style.display.block...

This also dosent mean that the relayout will work, maybe the css its just not correct for what you want to do...

Note: Window class inside has a check if the new size is diff then the previous one, just in this case fires the handler...

 Blaze
Reply all
Reply to author
Forward
0 new messages