Q:

How can we add Menu to Label in swt

How can I add Menu to label? I want to show a drop down menu by clicking on label to show some options to user. How is it possible in SWT?

A:

You can add a Menu to all Controls by calling Control#setMenu(Menu). Here is a small example for a Label:
public static void main(String[] args)
{
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("StackOverflow");
    shell.setLayout(new FillLayout());

    Label label = new Label(shell, SWT.NONE);
    label.setText("Right-click here");

    Menu menu = new Menu(label);
    MenuItem item = new MenuItem(menu, SWT.PUSH);
    item.setText("Context-menu item");
    item.addListener(SWT.Selection, new Listener()
    {
        @Override
        public void handleEvent(Event event)
        {
            System.out.println("clicked");
        }
    });

    label.setMenu(menu);

    shell.pack();
    shell.open();

    while (!shell.isDisposed())
    {
        if (!display.readAndDispatch())
        {
            display.sleep();
        }
    }
    display.dispose();
}

