package com.java2s.gwt.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.MenuBar;
import com.google.gwt.user.client.ui.RootPanel;
public class GWTClient implements EntryPoint{
public void onModuleLoad() {
MenuBar menu = new MenuBar();
MenuBar menuCreate = new MenuBar(true);
MenuBar menuHelp = new MenuBar(true);
Constants constants = (Constants) GWT.create(Constants.class);
menuHelp.addItem(constants.AboutMenuItemName(), new DummyCommand());
menuCreate.addItem(constants.ClockMenuItemName(), new DummyCommand());
menuCreate.addItem(constants.CalculatorMenuItemName(), new DummyCommand());
menuCreate.addItem(constants.permissionDenied("Joe","your password is wrong"), new DummyCommand());
menu.addItem(constants.HelpMenuName(), menuHelp);
menu.addItem(constants.CreateMenuName(), menuCreate);
menuCreate.addStyleName("submenu");
menuHelp.addStyleName("submenu");
RootPanel.get().add(menu);
}
}
public class DummyCommand implements Command{
public void execute() {
Window.alert("Menu Item Clicked");
}
}
/////
package com.java2s.gwt.client;
public interface Constants extends com.google.gwt.i18n.client.Messages {
/**
* Translated "About".
*
* @return translated "About"
* @gwt.key AboutMenuItemName
*/
String AboutMenuItemName();
/**
* Translated "Create".
*
* @return translated "Create"
* @gwt.key CreateMenuName
*/
String CreateMenuName();
/**
* Translated "Help".
*
* @return translated "Help"
* @gwt.key HelpMenuName
*/
String HelpMenuName();
/**
* Translated "Calculator".
*
* @return translated "Calculator"
* @gwt.key CalculatorMenuItemName
*/
String CalculatorMenuItemName();
/**
* Translated "Clock".
*
* @return translated "Clock"
* @gwt.key ClockMenuItemName
*/
String ClockMenuItemName();
String permissionDenied(String name, String message);
}
//////////////
HelpMenuName: Help
CreateMenuName: Create
AboutMenuItemName: About
CalculatorMenuItemName: Calculator
ClockMenuItemName: Clock
permissionDenied = Hi {0}, {1}
|