Exemplo n.º 1
0
  public Menu addMenu(String menuName, int width, String menuItemNames, ClickHandler clickHandler) {
    // initialise the new menu
    Menu menu = new Menu();
    menu.setTitle(menuName);
    menu.setShowShadow(true);
    menu.setShadowDepth(DEFAULT_SHADOW_DEPTH);
    menu.setWidth(width);

    // create an array of menu item names
    String[] menuItems = process(menuItemNames);

    for (int i = 0; i < menuItems.length; i++) {
      // remove any whitespace
      String menuItemName = menuItems[i].replaceAll("\\W", "");

      if (menuItemName.contentEquals(SEPARATOR)) {
        MenuItemSeparator separator = new MenuItemSeparator();
        menu.addItem(separator);
        continue;
      }

      MenuItem menuItem = new MenuItem(menuItems[i], getIcon(menuItems[i]));
      menuItem.addClickHandler(clickHandler);
      menu.addItem(menuItem);
    }

    Menu[] menus = new Menu[1];
    menus[0] = menu;
    menuBar.addMenus(menus, menuPosition);
    menuPosition++;

    return menus[0];
  }
Exemplo n.º 2
0
  public Menu addMenu(String menuName, int width) {
    // initialise the new menu
    Menu menu = new Menu();
    menu.setTitle(menuName);
    menu.setShowShadow(true);
    menu.setShadowDepth(DEFAULT_SHADOW_DEPTH);
    menu.setWidth(width);

    Menu[] menus = new Menu[1];
    menus[0] = menu;
    menuBar.addMenus(menus, menuPosition);
    menuPosition++;

    return menu;
  }