Adding menu bar to ContentPanel (Ext GWT) : ToolBar « GWT « Java






Adding menu bar to ContentPanel (Ext GWT)

Adding menu bar to ContentPanel (Ext GWT)
 

/*
 * Ext GWT - Ext for GWT
 * Copyright(c) 2007-2009, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */
 
 
package com.google.gwt.sample.hello.client;

import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.layout.FlowData;
import com.extjs.gxt.ui.client.widget.menu.Menu;
import com.extjs.gxt.ui.client.widget.menu.MenuBar;
import com.extjs.gxt.ui.client.widget.menu.MenuBarItem;
import com.extjs.gxt.ui.client.widget.menu.MenuItem;
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 MenuBarExample());

  }
}
class MenuBarExample extends LayoutContainer {

  @Override
  protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    
    Menu menu = new Menu();
    
    MenuItem item1 = new MenuItem("New");
    menu.add(item1);
    
    MenuItem item2 = new MenuItem("Open File");
    menu.add(item2);
    
    Menu sub = new Menu();
    sub.add(new MenuItem("readme.txt"));
    sub.add(new MenuItem("helloworld.txt"));
    item2.setSubMenu(sub);
    
    MenuBar bar = new MenuBar();
    bar.setBorders(true);
    bar.setStyleAttribute("borderTop", "none");
    bar.add(new MenuBarItem("File", menu));
    
    Menu sub2 = new Menu();
    sub2.add(new MenuItem("Cut"));
    sub2.add(new MenuItem("Copy"));
    
    MenuBarItem edit = new MenuBarItem("Edit", sub2);
    bar.add(edit);
    
    ContentPanel panel = new ContentPanel();
    panel.setHeading("MenuBar Example");
    panel.setTopComponent(bar);
    panel.setSize(400, 300);
    
    add(panel, new FlowData(10));
  }

}

   
  








Ext-GWT.zip( 4,297 k)

Related examples in the same category

1.Tool Strips Sample (Smart GWT)Tool Strips Sample (Smart GWT)
2.Adding ComboBox to ToolBar (Ext GWT)Adding ComboBox to ToolBar (Ext GWT)
3.ToolBar overflow (Ext GWT)
4.ToolBar with Dropdown menu (Ext GWT)ToolBar with Dropdown menu (Ext GWT)
5.Ribbon like ToolBar (Ext GWT)Ribbon like ToolBar (Ext GWT)
6.Multi-column no-title ToolBar (Ext GWT)Multi-column no-title ToolBar (Ext GWT)
7.ToolBar with grouped buttons (Ext GWT)ToolBar with grouped buttons (Ext GWT)
8.Office 2007 style toolbar (Ext GWT)Office 2007 style toolbar (Ext GWT)
9.Adding Status to ToolBar (Ext GWT)Adding Status to ToolBar (Ext GWT)
10.Add ToolBar to the bottom of a FormPanel (Ext GWT)Add ToolBar to the bottom of a FormPanel (Ext GWT)
11.Adding ToolBar to ContentPanel (Ext GWT)Adding ToolBar to ContentPanel (Ext GWT)
12.Using ButtonBar to hold buttons (Ext GWT)Using ButtonBar to hold buttons (Ext GWT)