parent.destroyAcceleratorTable ();
public void setMenu (Menu menu) {	checkWidget ();	/* Check to make sure the new menu is valid */	if ((style & SWT.CASCADE) == 0) {		error (SWT.ERROR_MENUITEM_NOT_CASCADE);	}	if (menu != null) {		if (menu.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);		if ((menu.style & SWT.DROP_DOWN) == 0) {			error (SWT.ERROR_MENU_NOT_DROP_DOWN);		}		if (menu.parent != parent.parent) {			error (SWT.ERROR_INVALID_PARENT);		}	}	/* Assign the new menu */	Menu oldMenu = this.menu;	if (oldMenu == menu) return;	if (oldMenu != null) oldMenu.cascade = null;	this.menu = menu;	/* Assign the new menu in the OS */		/*	* Feature in Windows.  When SetMenuItemInfo () is used to	* set a submenu and the menu item already has a submenu,	* Windows destroys the previous menu.  This is undocumented	* and unexpected but not necessarily wrong.  The fix is to	* remove the item with RemoveMenu () which does not destroy	* the submenu and then insert the item with InsertMenuItem ().	*/	int hMenu = parent.handle;	/* AW	MENUITEMINFO info = new MENUITEMINFO ();	info.cbSize = MENUITEMINFO.sizeof;	info.fMask = OS.MIIM_ID;	int index = 0;	while (OS.GetMenuItemInfo (hMenu, index, true, info)) {		if (info.wID == id) break;		index++;	}	if (info.wID != id) return;	int cch = 128;	int hHeap = OS.GetProcessHeap ();	int byteCount = cch * TCHAR.sizeof;	int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);	info.fMask = OS.MIIM_STATE | OS.MIIM_ID | OS.MIIM_TYPE;	info.dwTypeData = pszText;	info.cch = cch;	boolean success = OS.GetMenuItemInfo (hMenu, index, true, info);	if (menu != null) {		menu.cascade = this; 		info.fMask |= OS.MIIM_SUBMENU;		info.hSubMenu = menu.handle;	}	OS.RemoveMenu (hMenu, index, OS.MF_BYPOSITION);	if (OS.IsWinCE) {		success = OS.InsertMenu (hMenu, index, OS.MF_BYPOSITION, id, null); 		if (success) success = OS.SetMenuItemInfo (hMenu, index, true, info);	} else {		success = OS.InsertMenuItem (hMenu, index, true, info);	}	if (pszText != 0) OS.HeapFree (hHeap, 0, pszText);	if (!success) error (SWT.ERROR_CANNOT_SET_MENU);	parent.destroyAcceleratorTable ();	*/		short[] index= new short[1];	OS.GetIndMenuItemWithCommandID(hMenu, id, 1, null, index);	if (index[0] >= 1) {		OS.SetMenuItemHierarchicalMenu(hMenu, index[0], menu.handle);		// we set the menu's title to the item's title		int sHandle= 0;		try {			sHandle= OS.CFStringCreateWithCharacters(removeMnemonicsAndShortcut(getText()));			OS.SetMenuTitleWithCFString(menu.handle, sHandle);		} finally {			if (sHandle != 0)				OS.CFRelease(sHandle);		}	}}