Rob N
Rob N

Reputation: 16439

GWT DockLayoutPanel with browser determining size of some subpanels?

It looks like you have to specify absolute sizes of all but one subpanel. For example, from the GWT docs:

DockLayoutPanel p = new DockLayoutPanel(Unit.EM);
p.addNorth(new HTML("header"), 2);
p.addSouth(new HTML("footer"), 2);
p.addWest(new HTML("navigation"), 10);
p.add(new HTML(content));

But I want the north panel sized by the browser. I put some text or buttons in it and I don't know exactly what size it will be, I just know it is relatively thin and at the top of the page. And I want the content to take up the rest of the space, but no more, so there are no browser scroll bars. Is there a way to handle this with these newer layout panels?

Right now I'm using the older panels, and I have a handler attached with Window.addResizeHandler, which sets the height of the main content area so that everything fits within Window.getClientHeight

Update:

Thomas suggested a DockLayoutPanel inside a HeaderPanel, but this is not working for me:

<g:HeaderPanel>
 <g:Label>Header top</g:Label>
 <g:DockLayoutPanel unit='PX'>
   <g:west size='300'>
     <g:Label>West</g:Label>
   </g:west>
   <g:center>
     <g:Label>Center</g:Label>
   </g:center>
 </g:DockLayoutPanel>
</g:HeaderPanel>

"Header top" is there, the rest invisible. It looks like inner divs are getting 0 height.

Upvotes: 1

Views: 2592

Answers (1)

Thomas Broyer
Thomas Broyer

Reputation: 64561

You should put a DockLayoutPanel (for the west and center regions, possibly the south one too if you don't want it to use its natural height) in a HeaderPanel (for the natural sizing of the north region)

Upvotes: 1

Related Questions