Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT - Detect different screen resolutions while running

Tags:

events

gwt

I want my app to change different parts of the UI when the resolution is big enough and is on landscape mode, and detect changes while the app is running (screen rotation on a mobile device, for instance).

I know that I should have an event listen to the screen resolution (which can be obtained via javascript), but I don't know how to do this. How do I hang an event on a always refreshing value?

like image 406
Ineze Avatar asked Nov 11 '11 16:11

Ineze


1 Answers

You want Window.addResizeHandler

Window.addResizeHandler(new ResizeHandler() {

    @Override
    public void onResize(ResizeEvent event) {
        yourCustomLayoutAdjustmentMethod(event.getHeight(), event.getWidth());
    }
});

No JavaScript required!

like image 66
Riley Lark Avatar answered Oct 27 '22 00:10

Riley Lark