This section illustrates you how to create a menu bar.
In SWT, the classes Menu and MenuItem of package org.eclipse.swt.widgets is allowed to create a menu bar. The method setMenu() sets the pull down menu. The SWT.SEPERATOR separates the items of the menu. To perform an action on exitItem, the MenuItemListener class is called.
Following code close the shell on clicking the exit item:
if (((MenuItem) event.widget).getText().equals("Exit")) {
|
Here is the code of MenuExample.java
import org.eclipse.swt.SWT;
|
Output will be displayed as:

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Create Menu Bar in SWT
Post your Comment