Search code examples
smartgwt

SmartGWT TabSet height in window


I'm trying to have a TabSet in a Window. I would like the window to fit the contents so I turned autoSize on like I have done with many other windows. The window have a minimum width and height that I want it to be. My problem is that the TabSet in the Window doesn't fill up the height completely.

Here is my setup:

public MyWindow()
{

  setHeight(MIN_HEIGHT);
  setWidth(MIN_WIDTH);

  setAutoSize(true);

  theTabSet = new TabSet();
  theTabSet.setTabBarPosition(Side.TOP);
  theTabSet.setWidth100();
  theTabSet.setHeight100();

  // I need to set this for it to at least display the contents
  theTabSet.setPaneContainerOverflow(Overflow.VISIBL E);
  theTabSet.setOverflow(Overflow.VISIBLE);

  //This seems to solve my issue buy I think I shouldn't be doing this.
  theTabSet.setMinHeight(WINDOW_HEIGHT);

  Tab tab1 = new Tab("first");
  tab1.setPane(getFirstTab());

  Tab tab2 = new Tab("second");
  tab2.setTab(getSecondTab());

  addItem(theTabSet);

 }

  private Layout getFirstTab(){
   if(theFirstTab == null){
     theFirstTab = new VLayout();
     theFirstTab.setWidth100();
     theFirstTab().setHeight100();
   }
     return theFirstTab;
 }

Please let me know if I am missing something. According to the Layout API:

Like other Canvas subclasses, Layout and Stack components may have % width and height values. To create a dynamically-resizing layout that occupies the entire page (or entire parent component), set width and height to "100%


Solution

  • theTabSet.setMinHeight(WINDOW_HEIGHT);
    

    Seems to be the way to go. The window is set to fit it contents and the layout is set to fill the canvas. The window knows a minimum height and width but initially the layout doesn't know that. So we need to set it manually.