RootPanel root = RootPanel.get(ID);
if(root != null) init(root);
}
private void init(RootPanel root) {
MenuItem item;
Command command = new Command() {
public void execute() {
Window.alert("Click");
}
};
MenuBar menu = new MenuBar();
MenuBar file = new MenuBar(true);
MenuBar edit = new MenuBar(true);
MenuBar view = new MenuBar(true);
menu.addItem("File", file);
MenuItem editItem = (MenuItem)menu.addItem("Edit", edit);
menu.addItem("View", view);
item = (MenuItem)menu.addItem("Help", command);
item.setEnabled(false);
file.addItem("Open", command);
file.addItem("Close", command);
file.addItem("Save", command);
file.addItem("Exit", command);
edit.addItem("Undo", command);
edit.addItem("Redo", command);
edit.addItem("Cut", command);
edit.addItem("Copy", command);
edit.addItem("Paste", command);
editItem.setEnabled(false); // Disable after adding children so they get disabled too
view.addItem("Date", true, command, MenuItem.Type.CHECK, false);
view.addItem("Time", true, command, MenuItem.Type.CHECK, true);
view.addSeparator();
view.addItem("Radio 1", true, command, MenuItem.Type.RADIO, false);
view.addItem("Radio 2", true, command, MenuItem.Type.RADIO, true);