Creating a fluid panel in GWT to fill the page?

前端 未结 8 2121
不思量自难忘°
不思量自难忘° 2021-02-05 09:53

I would like a panel in GWT to fill the page without actually having to set the size. Is there a way to do this? Currently I have the following:

public class M         


        
8条回答
  •  自闭症患者
    2021-02-05 10:17

    Google has answered the main part of your question in one of their FAQs: http://code.google.com/webtoolkit/doc/1.6/FAQ_UI.html#How_do_I_create_an_app_that_fills_the_page_vertically_when_the_b

    The primary point is that you can't set height to 100%, you must do something like this:

    final VerticalPanel vp = new VerticalPanel();
    vp.add(mainPanel);
    vp.setWidth("100%");
    vp.setHeight(Window.getClientHeight() + "px");
    Window.addResizeHandler(new ResizeHandler() {
    
      public void onResize(ResizeEvent event) {
        int height = event.getHeight();
        vp.setHeight(height + "px");
      }
    });
    RootPanel.get().add(vp);
    

提交回复
热议问题