Menu menu = new Menu(shell, SWT.DROP_DOWN);
item.setMenu(menu);
/**
* Adds a listener to handle enabling and disabling some items in the Edit submenu.
*/
menu.addMenuListener(new MenuAdapter() {
public void menuShown(MenuEvent e) {
Menu menu = (Menu) e.widget;
MenuItem[] items = menu.getItems();
items[1].setEnabled(table.getSelectionCount() != 0); // edit contact
items[5].setEnabled(file != null && isModified); // save