Creating a DockLayoutPanel with non-fixed sizes ?

1,525 views
Skip to first unread message

Eric Andresen

unread,
Apr 14, 2011, 6:13:12 PM4/14/11
to google-we...@googlegroups.com
Does anyone know if it is possible to create a layout panel that behaves like a dock layout panel, but allows the outer panels to size to their "natural" sizes?

What I'm trying to accomplish is a panel with a north and a center.  I want the North panel to size to the natural height of its contents, and the center to take up the remaining space.  The top panel can change in size, and I would like the bottom panel to automatically resize when that happens.  

Is there a panel that can do something like "Given two widgets, lay the first one out, and then give all remaining space to the second" ?  Kind of an auto-adjusting SplitLayoutPanel.

My other thought was to use a standard DockLayoutPanel or LayoutPanel, but somehow attach a listener to the scrollHeight property of the north's FlowPanel that triggers a resize of the north layer.  
Does anyone know if there is a way to register for an event that a FlowPanel's content's height has changed?

Thanks,
Eric

Magnus

unread,
Apr 14, 2011, 10:37:05 PM4/14/11
to Google Web Toolkit
Hi,

I wanted to do the same, i. e. have a MenuBar at the top and set it to
its "natural" size. I remember that I posed nearly the same question
here. But I still have no solution for this. I set the height of the
upper panel manually, resulting in a Menubar that is too high on most
systems.

Magnus

rjcarr

unread,
Apr 15, 2011, 3:33:48 AM4/15/11
to Google Web Toolkit
Hi Eric-

I'm not seeing why a DockPanel or a VerticalPanel won't do what you
ask. If you don't set a fixed size for the panel's cells it should
readjust whenever the content in those cells change.

It sounds like you want the "center" panel to take up the remaining
space of the window? If that's the case it can be done, but generally
heights are tricky to specify in browsers.

Good luck.

Alexandre Ardhuin

unread,
Apr 15, 2011, 4:23:25 AM4/15/11
to google-we...@googlegroups.com
Suppose that you have :

    <g:DockLayoutPanel unit='PX' ui:field="dlp">
        <g:north size='100'>
            <g:SimplePanel ui:field="headerContainer">
                <g:HTMLPanel ui:field="headerContent">
                    (... content that can change ...)
                </g:HTMLPanel>
            </g:SimplePanel>
        </g:north>
        <g:center>
             (...)
        </g:center>
    </g:DockLayoutPanel>

You can manually resize header after a modification of his content by calling :

        dlp.setWidgetSize(headerContainer, headerContent.getOffsetHeight());
        dlp.forceLayout();


Alexandre


2011/4/15 Eric Andresen <erican...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Thomas Broyer

unread,
Apr 15, 2011, 6:02:13 AM4/15/11
to google-we...@googlegroups.com
GWT 2.3 will come with a HeaderPanel for this exact purpose: http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/user/client/ui/HeaderPanel.java
It's already in the 2.3 M1 if you want to test it.

Eric Andresen

unread,
Apr 15, 2011, 7:46:07 AM4/15/11
to google-we...@googlegroups.com, Thomas Broyer
Thanks, Thomas!

You guys always seem to be one step (or release) ahead of me!
---------------------------------------------------
Eric Andresen


On Fri, Apr 15, 2011 at 5:02 AM, Thomas Broyer <t.br...@gmail.com> wrote:
GWT 2.3 will come with a HeaderPanel for this exact purpose: http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/user/client/ui/HeaderPanel.java
It's already in the 2.3 M1 if you want to test it.

--

Thomas Broyer

unread,
Apr 15, 2011, 6:48:05 PM4/15/11
to google-we...@googlegroups.com


On Friday, April 15, 2011 1:46:07 PM UTC+2, Eric Andresen wrote:
Thanks, Thomas!

You guys always seem to be one step (or release) ahead of me!

We're running a patched build out of "trunk", and I'm subscribed to the RSS feeds for both commits and code reviews: it helps a lot in keeping up-to-date!
Reply all
Reply to author
Forward
0 new messages