So far, we have modified menus before they are created, by adding items to them. Sometimes it is necessary to modify a menu after it is created.
The SelfModifyingMenu illustrated in Figure 17-7 contains an item that which is either enabled or and disabled by the menu item above it. SelfModifyingMenu also contains two menu items for adding an item and removing the last item added to the menu.
Example 17-10 lists the SelfModifyingMenu class.