Add click handler for Menu item (Smart GWT) : Menu « GWT « Java

Home
Java
1.2D Graphics GUI
2.3D
3.Advanced Graphics
4.Ant
5.Apache Common
6.Chart
7.Class
8.Collections Data Structure
9.Data Type
10.Database SQL JDBC
11.Design Pattern
12.Development Class
13.EJB3
14.Email
15.Event
16.File Input Output
17.Game
18.Generics
19.GWT
20.Hibernate
21.I18N
22.J2EE
23.J2ME
24.JDK 6
25.JNDI LDAP
26.JPA
27.JSP
28.JSTL
29.Language Basics
30.Network Protocol
31.PDF RTF
32.Reflection
33.Regular Expressions
34.Scripting
35.Security
36.Servlets
37.Spring
38.Swing Components
39.Swing JFC
40.SWT JFace Eclipse
41.Threads
42.Tiny Application
43.Velocity
44.Web Services SOA
45.XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Java » GWT » MenuScreenshots 
Add click handler for Menu item (Smart GWT)
Add click handler for Menu item (Smart GWT)
   
/*
 * SmartGWT (GWT for SmartClient)
 * Copyright 2008 and beyond, Isomorphic Software, Inc.
 *
 * SmartGWT is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License version 3
 * as published by the Free Software Foundation.  SmartGWT is also
 * available under typical commercial license terms - see
 * http://smartclient.com/license
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 */
package com.smartgwt.sample.showcase.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.menu.Menu;
import com.smartgwt.client.widgets.menu.MenuButton;
import com.smartgwt.client.widgets.menu.MenuItem;
import com.smartgwt.client.widgets.menu.MenuItemSeparator;
import com.smartgwt.client.widgets.menu.MenuItemStringFunction;
import com.smartgwt.client.widgets.menu.events.ClickHandler;
import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;

public class Showcase implements EntryPoint {

  public void onModuleLoad() {
    RootPanel.get().add(getViewPanel());
  }

  public Canvas getViewPanel() {
    Menu menu = new Menu();
    menu.setShowShadow(true);
    menu.setShadowDepth(10);

    MenuItem newItem = new MenuItem("New""icons/16/document_plain_new.png""Ctrl+N");
    MenuItem openItem = new MenuItem("Open""icons/16/folder_out.png""Ctrl+O");
    MenuItem saveItem = new MenuItem("Save""icons/16/disk_blue.png""Ctrl+S");
    MenuItem saveAsItem = new MenuItem("Save As""icons/16/save_as.png");

    MenuItem recentDocItem = new MenuItem("Recent Documents""icons/16/folder_document.png");

    Menu recentDocSubMenu = new Menu();
    MenuItem dataSM = new MenuItem("data.xml");
    dataSM.setChecked(true);
    MenuItem componentSM = new MenuItem("Component Guide.doc");
    MenuItem ajaxSM = new MenuItem("AJAX.doc");
    recentDocSubMenu.setItems(dataSM, componentSM, ajaxSM);

    recentDocItem.setSubmenu(recentDocSubMenu);

    MenuItem exportItem = new MenuItem("Export as...""icons/16/export1.png");
    Menu exportSM = new Menu();
    exportSM.setItems(
            new MenuItem("XML"),
            new MenuItem("CSV"),
            new MenuItem("Plain text"));
    exportItem.setSubmenu(exportSM);

    MenuItem printItem = new MenuItem("Print""icons/16/printer3.png""Ctrl+P");
    printItem.setEnabled(false);

    MenuItemSeparator separator = new MenuItemSeparator();

    final MenuItem activateMenu = new MenuItem("Activate");
    activateMenu.setDynamicTitleFunction(new MenuItemStringFunction() {

        public String execute(final Canvas aTarget, final Menu aMenu, final MenuItem aItem) {
            if (Math.random() 0.5) {
                return "De-Activate Blacklist";
            else {
                return "Activate Blacklist";
            }
        }
    });

    activateMenu.addClickHandler(new ClickHandler() {

        public void onClick(final MenuItemClickEvent event) {
            //processStateChangeEvent();
        }
    });

    menu.setItems(activateMenu, newItem, openItem, separator, saveItem, saveAsItem,
            separator, recentDocItem, separator, exportItem, separator, printItem);

    return new MenuButton("File", menu);
  }
}

   
    
    
  
SmartGWT.zip( 9,880 k)
Related examples in the same category
1.Menu with style
2.Drop down menu (Smart GWT)Drop down menu (Smart GWT)
3.Menu item separator (Smart GWT)Menu item separator (Smart GWT)
4.Menu item with icon (Smart GWT)Menu item with icon (Smart GWT)
5.Set shortcut key for Menu item (Smart GWT)Set shortcut key for Menu item (Smart GWT)
6.Change Menu item title with customized action (Smart GWT)Change Menu item title with customized action (Smart GWT)
7.Menu Custom Columns Sample (Smart GWT)Menu Custom Columns Sample (Smart GWT)
8.Set up sub menu item (Smart GWT)Set up sub menu item (Smart GWT)
9.Menu Tree Binding Sample (Smart GWT)Menu Tree Binding Sample (Smart GWT)
10.Custom Header Menu Sample (Smart GWT)Custom Header Menu Sample (Smart GWT)
11.Adding CheckMenuItem to ToolBar (Ext GWT)Adding CheckMenuItem to ToolBar (Ext GWT)
12.Creating submenu (Ext GWT)Creating submenu (Ext GWT)
13.Desktop in a browser (Ext GWT)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.