Google Web Toolkit 2 Application Development Cookbook
上QQ阅读APP看书,第一时间看更新

Creating the main content panel

In this recipe, we are going to create the main content panel, to be placed at the center. All forms and reports will be shown in this panel.

How to do it...

  1. Define the method getMainContents:
    public ContentPanel getMainContents()
    {
    ContentPanel mainContentsPanel = new ContentPanel();
    mainContentsPanel.setHeading("Main Contents");
    return mainContentsPanel;
    }
    
  2. Call the add method of the ContentPanel class in the constructor to add the sidebar in the content panel:
    add(getMainContents(), mainContentsLayoutData);
    

How it works...

The method getMainContents creates a ContentPanel instance and sets a heading Main Contents. This heading will be modified later.

The content panel created by this method is added at the center of the home page content panel by invoking add(getMainContents(), mainContentsLayoutData) in the constructor.

See also

  • The Creating the home page layout class recipe
  • The Adding the banner recipe
  • The Adding menus recipe
  • The Creating the left-hand sidebar recipe
  • The Creating the right-hand sidebar recipe
  • The Creating the footer recipe
  • The Using the HomePage instance in EntryPoint recipe