Search code examples
gwtuibindergwt2

centering an element in the decorative popup panel in gwt


the pop up is a decorative pop up , the text in it is a label and close is a button. i have added the label and a button to horizontal panel and then added it to popup panel. i have tried with both invalidEntryVpanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); invalidEntryVpanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

but still not able to align it in center please help. thanks in advance


Solution

  • Try like this

    You have to add the widgets after you set the align center

    VerticalPanel vpnPanel = new VerticalPanel();
            vpnPanel.add(scrollPanel);   //all controls added to scrill panel with help of set widget 
            vpnPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
            HorizontalPanel btnLayoutPanel = new HorizontalPanel();
            btnLayoutPanel.setSpacing(10);
            btnLayoutPanel.add(closeButton);
            vpnPanel.add(btnLayoutPanel);
            decPopuppanel.setWidget(vpnPanel);