Adding Separator Bars

If you examine the menu system for an application running on your chosen platform, you may see that individual menu items are often separated by a line, enabling you to divide the items in a cascading menu into functional groups.

How do I do that?

A separator is simply an instance of MenuItem that has been given the SWT.SEPARATOR style:

MenuItem separator = new MenuItem(filemenu, SWT.SEPARATOR);

A separator menu item will take no action and cannot be clicked.

Note

A menu without separators may function okay, but it just won’t look good.

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.