Question

    int browserHeight=Window.getClientHeight();
    int browserWidth=Window.getClientWidth();
    dialog.setPopupPosition(browserWidth-dialog.getElement().getClientWidth(), browserHeight-dialog.getElement().getClientHeight());

    dialog.show();

The above code will make the position starts from the very last pixel of the browser (ie bottom=0), which is not what i expect. I don't like css cos browser incompatible problem. Also there a footer in my website (height=50px) if u can make the dialog to not to lay on the footer like the following pic enter image description here

so, How to position the GWT dialog to the bottom right corner of the browser?

Was it helpful?

Solution

This is the right way

dialogBox.setPopupPositionAndShow(new PositionCallback(){

    @Override
    public void setPosition(int offsetWidth, int offsetHeight) {
                        // TODO Auto-generated method stub
        dialogBox.setPopupPosition(parentDockLayoutPanel().getOffsetWidth()-         dialogBox.getOffsetWidth(), 
parentDockLayoutPanel().getOffsetHeight() - dialogBox.getOffsetHeight()-50);
    }

});

OTHER TIPS

It will be simple if we know the exact width & height of dialogbox. We also need to to know the parentPanel / parentLayoutPanel of dialogbox

This code will work but it is not the optimum code

dialogBox.setWidth("300px");
dialogBox.setHeight("300px");
dialogBox.setPopupPosition(parentLayoutPanel.getOffsetWidth()-300,parentLayoutPanel.getOffsetHeight()-300-50);

but how to know the width + height of dialogbox dynamically is another question

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top