tags:

views:

341

answers:

2

It is a little bit annoying to have the GWT hosted browser (on a Mac) pop up at always the same screen location and same size (that is: to small and at the wrong place!). In particular if you have two 24" monitors it couldn't be less annoying to always move the browser window and to resize it on startup. I know I could leave it open and reload, but I'm used to the cmd+shift+F11 and then cmd-Q to quit cycle as I do in other programs. Another reason is that in hosted mode GWT leaks memory and after a couple (about 20) reloads I have to quit anyway.

Does anybody know a way to tell the hosted mode app the initial size of the browser frame and possibly it's location? If not I will eventually file a feature request at GWT.

A: 

I don't think there is a way yet, but see this issue in the tracker for a possible patch (might not work anymore) and some explanation.

Peter Recore
+1  A: 

One thing you could try is to have a separate module class for hosted mode testing that is a subclass of your actual module. In the hosted mode version of the module, you could have some JSNI that resizes the window:

public class MyModule implements EntryPoint {
    //...
 }


public class HostedModeMyModule extends MyModule {
    private native void resizeWindow() /*-{
        $wnd.resizeTo(800, 600);
    }-*/;

    public void onModuleLoad() {
        resizeWindow();
        super.onModuleLoad();
    }
 }

You'll have to have two gwt.xml file of course, one for testing and one for compilation.

This isn't the most elegant approach, but is all I can come up with.

Jack Leow
It is an approach, indeed. I was more hoping for some -D... property or cmd line argument which I didn't catch in the docs.
Andre Pareis