Unfortunately this isn't simple.
Because of the hard-coded "height:100%" for the deck panel, setting the
height of the tabpanel always makes it bigger than you wanted (by the height
of the tabs)
You have to calculate it and recalculate it every time the window resizes,
something like this
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.logical.shared.ResizeEvent;
import com.google.gwt.event.logical.shared.ResizeHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TabPanel;
public class Example implements EntryPoint, ResizeHandler
{
TabPanel t = new TabPanel();
@Override
public void onModuleLoad()
{
RootPanel.get().add(t);
t.add(new Label("Content A"), "Tab A");
t.add(new Label("Content B"), "Tab B");
t.selectTab(0);
t.getElement().getStyle().setProperty("backgroundColor", "cyan");
Window.addResizeHandler(this);
resize();
}
@Override
public void onResize(ResizeEvent event)
{
resize();
}
private void resize()
{
t.setPixelSize(Window.getClientWidth(), Window.getClientHeight() -
t.getTabBar().getOffsetHeight());
}
}
You also need to set the html and body element margins, borders and padding
to 0, or add them in to the calculation
Ian
http://examples.roughian.com
2009/8/15 David Given <[email protected]>
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> I'm trying to make a dead simple layout where a TabPanel occupies the
> full height of the browser window. This is turning out to be rather
> harder than I expected.
>
> What I'm finding is:
>
> - - setting the height of the TabPanel to 100% changes the height of the
> enclosing box, but the UI (the box around the deck area) is still sized
> according to the content, so is far too small.
>
> - - setting the height of the content to 100% does nothing.
>
> - - setting the height of the TabPanel's deck *almost* works --- but the
> height is calculated before the deck's border and padding is added, so
> setting the height to 100% actually makes the tab UI a little bit bigger
> than the available area.
>
> This can't be as hard as it looks --- what am I missing?
>
> - --
> ┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
> │
> │ "People who think they know everything really annoy those of us who
> │ know we don't." --- Bjarne Stroustrup
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iD8DBQFKhvvMf9E0noFvlzgRAlNnAKCWIzkxgUtNjlxiyjperRrELD6BrgCguAL2
> cp6ORjFnRFMY32rvMfhBRNQ=
> =gt9J
> -----END PGP SIGNATURE-----
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---