Creating Menus

First, we will discuss menu bars. To use a menu bar, perform the following actions:

■ Attach the menu bar to the frame

■ Create the individual menus

■ Attach the menus to the menu bar or to a parent menu

■ Create the individual menu items

■ Attach the menu items to the appropriate menu

■ Create an event binding for each menu item

The order in which you perform these actions is somewhat flexible, as long as you create all items before use, and all actions are completed in the frame initialization method. You can manipulate the menus later in the process, but after the frame is visible, the order in which you do things may affect what the user sees. For example, it doesn't matter if you attach the menu bar to the frame right after creation, or if you wait until all other procedures are complete. For readability and maintenance purposes, we recommend that you keep related components together. For suggestions on how to organize menu creation, see the section on refactoring in chapter 5. In the next sections, we'll cover basic menu tasks.

Was this article helpful?

0 0

Post a comment