Code:
package com.google.gwt.sample.hello.client;

import java.util.ArrayList;
import java.util.List;

import com.extjs.gxt.ui.client.data.BaseModelData;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.ModelKeyProvider;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.TreePanelEvent;
import com.extjs.gxt.ui.client.store.TreeStore;
import com.extjs.gxt.ui.client.widget.Html;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
import com.extjs.gxt.ui.client.widget.myTreepanel.TreePanel;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.RootPanel;

public class Hello implements EntryPoint {
  public void onModuleLoad() {
    RootPanel.get().add(new FastTreePanelExample());
  }
}
class FastTreePanelExample extends LayoutContainer {
  private int valCnt = 0;

 
  protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    setLayout(new FlowLayout(12));

    final Html html = new Html("This myTree is handling one child. Expand to get more!");
    html.setStyleName("pad-text");

    LayoutContainer container = new LayoutContainer();
    container.setSize(300, 350);
    container.setBorders(true);
    container.setLayout(new FitLayout());

    TreeStore<ModelData> store = new TreeStore<ModelData>();
    final TreePanel<ModelData> myTree = new TreePanel<ModelData>(store);
    myTree.setTrackMouseOver(false);
    myTree.setDisplayProperty("name");
    store.setKeyProvider(new ModelKeyProvider<ModelData>() {

      public String getKey(ModelData model) {
        return model.get("id");
      }

    });
    ModelData m = creater("Fast Tree");
    store.add(m, false);

    myTree.setLeaf(m, false);

    myTree.addListener(Events.BeforeExpand, new Listener<TreePanelEvent<ModelData>>() {

      public void handleEvent(TreePanelEvent<ModelData> be) {
        if (be.getNode().getItemCount() != 0) {
          return;
        }
        List<ModelData> list = new ArrayList<ModelData>();
        for (int i = 0; i < 500; i++) {
          ModelData m = creater("Tree Item " + i);
          list.add(m);
        }

        myTree.getStore().insert(be.getNode().getModel(), list, 0, true);
        for (ModelData m : list) {
          myTree.setLeaf(m, false);
        }
      }
    });

    myTree.addListener(Events.Expand, new Listener<TreePanelEvent<ModelData>>() {

      public void handleEvent(TreePanelEvent<ModelData> be) {
        html.setHtml("<span>This myTree is handling " + myTree.getStore().getAllItems().size()
            + " children. Expand to get more!</span>");

      }

    });

    add(html);
    container.add(myTree);
    add(container);
    
  }

  private ModelData creater(String n) {
    ModelData m = new BaseModelData();
    m.set("name", n);
    m.set("id", String.valueOf(valCnt++));
    return m;
  }

}