1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| // A command for general use
Command command = new Command()
{
public void execute()
{
Window.alert("Command Fired");
}
};
// Top-level menu
MenuBar menutop = new MenuBar();
menutop.addStyleName("demo-MenuItem");
// Item to fire a command
MenuItem fireone = new MenuItem("Fire One", command);
// Level-two menu - vertical=true
MenuBar menutwo = new MenuBar(true);
menutwo.addStyleName("demo-MenuItem");
// Items for menu two
MenuItem firetwo = new MenuItem("Fire Two", command);
MenuItem firethree = new MenuItem("Fire Three", command);
MenuItem firefour = new MenuItem("Fire Four", command);
// Assemble the menu system
menutop.addItem(fireone); // Adds existing item
menutop.addItem("SubMenu", menutwo); // Creates item and adds menutwo
menutwo.addItem(firetwo);
menutwo.addItem(firethree);
menutwo.addItem(firefour); |
Partager