• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 3. SWT Menus > Adding Drop-Down Menus

3.2. Adding Drop-Down Menus

Executing MenuShell won't display a menu system because no high-level menus have been created and added to the menu bar. To do that, you need to create instances of the MenuItem class using the SWT.CASCADE style.

3.2.1. How do I do that?

Create an instance of the MenuItem class for each desired drop down and set the text attribute of each such instance to represent the clickable text the user will see. These instances of MenuItem are what the user will see running across the menu bar (e.g., File). Instances of MenuItem are attached directly to the menu bar by passing a reference to the menu bar in the MenuItem constructor. These MenuItem objects must be given the SWT.CASCADE style. The setText( ) method is called to specify the text you wish to appear on the menu:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint