Chapter 3. SWT Menus

In this chapter you continue your examination of the SWT by looking at another component for designing professional-looking windows—menus. In SWT, the classes provided to help you create menus are Menu and MenuItem, both located in the org.eclipse.swt.widgets package.

Menus are the primary application navigation tool you provide for your users, and it is a rare application that doesn’t make use of them. The published standards for designing GUIs specify the types of windows that should display a menu, the functionality the menu should provide, and the names of specific menu items. You can get the same guidance by examining the menu structure of almost any application running on your target platform.

Tip

The menu guidelines vary somewhat by platform as far as specific names to be given to menu items and the actual menu structure (what appears under File or Edit, for example). This presents somewhat of a problem for “write once, run anywhere” programming, because SWT won’t help when it comes to names, labels, or locations of menu items. As time goes by, the standards for graphical design are merging and this issue will someday vanish into these (theoretical) merged standards. For now, following the Microsoft guidelines should suffice for most platforms.

Most applications will have a minimum of File, Edit, Window, and Help as high-level menu choices, with submenu items varying depending upon the application’s functionality. Edit, for example, will almost certainly ...

Get SWT: A Developer's Notebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.