curPhrase = (curPhrase + 1) % phrases.length;
}
};
// Create a menu bar
MenuBar menu = new MenuBar();
menu.setAutoOpen(false);
menu.setWidth("500px");
menu.setAnimationEnabled(true);
// Create a sub menu of recent documents
MenuBar recentDocsMenu = new MenuBar(true);
String[] recentDocs = new String[]{"Fishing in the desert.txt",
"How to tame a wild parrot", "Idiots Guide to Emu Farms"};
for (int i = 0; i < recentDocs.length; i++) {
recentDocsMenu.addItem(recentDocs[i], menuCommand);
}
// Create the file menu
MenuBar fileMenu = new MenuBar(true);
fileMenu.setAnimationEnabled(true);
menu.addItem(new MenuItem("File", fileMenu));
String[] fileOptions = new String[]{"New", "Open", "Close", "Recents",
"Exit"};
for (int i = 0; i < fileOptions.length; i++) {
if (i == 3) {
fileMenu.addSeparator();
fileMenu.addItem(fileOptions[i], recentDocsMenu);
fileMenu.addSeparator();
} else {
fileMenu.addItem(fileOptions[i], menuCommand);
}
}
// Create the edit menu
MenuBar editMenu = new MenuBar(true);
menu.addItem(new MenuItem("Edit", editMenu));
String[] editOptions = new String[]{"Undo", "Redo", "Copy", "Cut",
"Paste"};
for (int i = 0; i < editOptions.length; i++) {
editMenu.addItem(editOptions[i], menuCommand);
}
// Create the GWT menu
MenuBar gwtMenu = new MenuBar(true);
menu.addItem(new MenuItem("GWT", true, gwtMenu));
String[] gwtOptions = new String[]{"Download", "Examples", "Source code",
"GWT wit' the program"};
for (int i = 0; i < gwtOptions.length; i++) {
gwtMenu.addItem(gwtOptions[i], menuCommand);
}
// Create the help menu
MenuBar helpMenu = new MenuBar(true);
menu.addSeparator();
menu.addItem(new MenuItem("Help", helpMenu));
String[] helpOptions = new String[]{"Contents", "Fortune cookies",
"About GWT"};
for (int i = 0; i < helpOptions.length; i++) {
helpMenu.addItem(helpOptions[i], menuCommand);
}
// Return the menu
menu.ensureDebugId("cwMenuBar");
return menu;