tags:

views:

298

answers:

3

I'm using a TabLayoutPanel in a GWT application, attached to the RootLayoutPanel of the page.

Inside each tab I have a ScrollPanel, which is used to display a FlexTable.

Is it possible to make the TabLayoutPanel grow vertically, so the user can scroll the entire page using the browser scroll bar, instead of using the internal ScrollPanel ?

A: 

If you make the TabLayoutPanel bigger than the root panel, you will get a browser scroll bar.

rep_movsd
I removed the ScrollPanel, adding the FlexTable directly to the TabLayoutPanel. However, as the FlexTable grows with the new items added to it, the TabLayoutPanel height doesn't change. Do I have to call a specific method to layout the panel again ?
muriloq
A: 

If I want to achieve something like this, I always put the TabLayoutPanel in a SimplePanel and add the SimplePanel to the RootPanel. I guess this is not the best way, but it works.

public void onModuleLoad() {
   //Create TabPanel
   TabPanel tp = new TabPanel();
   tp.add(new HTML("Foo"), "foo");
   tp.add(new HTML("Bar"), "bar");
   tp.add(new HTML("Baz"), "baz");
   tp.selectTab(1);
   // Create SimplePanel and add TabPanel
   SimplePanel sp =new SimplePanel();
   sp.add(tp);
   // Add SimplePanel to the root panel.
   RootPanel.get().add(sp);
}
Chris Boesing
It didn't work, probably because I'm using TabLayoutPanel, introduced in GWT 2.0, not TabPanel. Here's a thread discussing the same problem:http://www.coderanch.com/t/493012/Google-Web-Toolkit/Application-Frameworks/TabLayoutPanel-auto-height-grow-gwt
muriloq
Why not use the TabPanel instead? Isn't the only benefit of the *LayoutPanels that they are automatically attached to the RootPanel?
Chris Boesing
+2  A: 

The short answer is: It's not possible with LayoutPanel's. The reason: LayoutPanel's are specific for applications that need to fill the browser client area, or in other words the part that is visible by the user. One of the problems with browsers is to have a widget that has exactly the height of the visible area and also automatically resizes when the browser window is resized. This is one of the problems the LayoutPanels solve.

If you want to use the browser scrollbar and be able to create pages longer than the visible area use the 'normal' Panels.

BTW just FYI you are aware the FlexTable is slow in rendering and if possible better use Grid.

Hilbrand