#1603 Trouble with Child Widget in FWT

RedDevil Thu 4 Aug 2011

I am new to Fantom and I am having difficulty getting a FWT application working. basically I want TabPane within TabPane but I can not get anything to display in the child tabs. Here is what I have (probably just missing something simple so any help would be appreciated: using gfx using fwt class FwtDemo {

Void main()
{
  Window
  {
    content = EdgePane
    {
      center = TabPane
      {
        Tab { text = "Terminal Config";       makeTextGrid, },
      }
    }
  }.open
}
Widget makeTextGrid()
{
  return EdgePane
  {
    center = TabPane
    {
          Tab { text = "TAB 1";         InsetPane { tab1  }, },
    }
  }
}

Widget tab1() {

return GridPane
{
  numCols = 2
  hgap = 20
  Button { mode = ButtonMode.radio; text = "B6" },
  Text {text = "LEFT"},
}
}

} Apology for not understanding posting protocol. RedDevil

DanielFath Thu 4 Aug 2011

Hi, welcome to the forums! Protocol for posting isn't that hard. Just indent code by two spaces (replace dots with space). For example:

..Void static main()

becomes:

Void static main()

As for your code it's ok, except you missed a , (comma) in InsetPane { tab1 }, and since coma is shortcut for add operator your tab was never added or declared child. There are many ways to solve this below is one.

Alternatives are InsetPane { content = tab1 }, or InsetPane { add(tab1) },

using fwt
using gfx
**
**
**
class FwtDemo {

  Void main()
  {
      Window
      {
        content = EdgePane
        {
          center = TabPane
          {
            Tab { text = "Terminal Config";       makeTextGrid, },
          }
        }
      }.open
  }


  Widget makeTextGrid()
  {
    return EdgePane
    {
      center = TabPane
      {
            Tab { text = "TAB 1";   InsetPane { tab1,  }, },  //InsetPane { tab1  },
      }
    }
  }

  Widget tab1() {


    return GridPane
    {
      numCols = 2
      hgap = 20
      Button { mode = ButtonMode.radio; text = "B6" },
      Text {text = "LEFT"},
    }
  }
}

RedDevil Thu 4 Aug 2011

Thank You. I suspected it was something to do with add but I missed the fact that the , was doing that in the examples.

Login or Signup to reply.