示例效果图
示例代码
package fan.tutorial.client.ui.bar;
import com.extjs.gxt.ui.client.util.IconHelper;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.menu.Menu;
import com.extjs.gxt.ui.client.widget.menu.MenuItem;
import com.extjs.gxt.ui.client.widget.menu.SeparatorMenuItem;
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.user.client.Element;
public class ToolBarExample extends LayoutContainer {
@Override
protected void onRender(Element parent, int index) {
super.onRender(parent, index);
//创建内容面板
ContentPanel panel = new ContentPanel();
panel.setHeadingHtml("ToolBar Example");
panel.setSize(650, 400);
//创建2个图标Button
Button addUserButton = new Button("Add User", IconHelper.createStyle("user-add-icon"));
Button deleteUserButton = new Button("Delete User", IconHelper.createStyle("user-delete-icon"));
//创建一个菜单
Menu addUserMenu = new Menu();
//为菜单添加2个操作选项
addUserMenu.add(new MenuItem("Add"));
addUserMenu.add(new SeparatorMenuItem());
addUserMenu.add(new MenuItem("Existing import"));
//设置为按钮菜单
addUserButton.setMenu(addUserMenu);
//将按钮添加到ToolBar
ToolBar toolBar = new ToolBar();
toolBar.add(addUserButton);
toolBar.add(new SeparatorToolItem());
toolBar.add(deleteUserButton);
toolBar.add(new SeparatorToolItem());
//设置面板的ToolBar
panel.setTopComponent(toolBar);
add(panel);
}
}
posted on 2014-06-08 12:57
fancydeepin 阅读(1138)
评论(0) 编辑 收藏