PDA

View Full Version : How to put tabs inside of ContentPanel



Konstantin.Solomatov
16 Jan 2009, 2:10 AM
I want to create a tab with content panel inside of it (like in Explorer application).

I use the following code


public class Gxtsandbox implements EntryPoint {
public void onModuleLoad() {
Viewport viewport = new Viewport();
viewport.setLayout(new AnchorLayout());

ContentPanel content = new ContentPanel();
content.setLayout(new AnchorLayout());
content.add(createTabPanel(), new AnchorData("100% 100%"));
content.setAutoHeight(true);
content.setHeading("Heading");

viewport.add(content, new AnchorData("100% 100%"));

RootPanel.get().add(viewport);

}

private TabPanel createTabPanel() {
TabPanel tabPanel = new TabPanel();
tabPanel.setMinTabWidth(70);
tabPanel.setBorderStyle(false);
tabPanel.setBodyBorder(false);
tabPanel.setTabPosition(TabPanel.TabPosition.BOTTOM);

TabItem treeItem = new TabItem();
treeItem.setText("Tab 1");
treeItem.add(new LabelField("Tab 1"));
tabPanel.add(treeItem);

TabItem listItem = new TabItem();
listItem.setText("Tab 2");
listItem.add(new LabelField("Tab 2"));
tabPanel.add(listItem);

return tabPanel;
}
}


Instead of tabs which fill the whole ContentPanel I get only part of ContentPanel's space devoted to it.

What am I doing wrong? May be I don't understand how layouts work.

timefortea
19 Jan 2009, 5:39 AM
Take a look at the code provided in the following bug report. Aside from the faulty accordion panel being reported, you can see a tab panel which contains a border layout and will fill the browser space. Of most interest is the use of FitLayout, which means the item will expand to fill the space of its parent container.

http://extjs.com/forum/showthread.php?t=53017

Good luck.