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:

|
Recommend the tutorial |

Ask Questions? Discuss: Create Menu Bar in SWT
Post your Comment