Creating a menu with SWT

Main.java:

import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
 
public class Main
{
   public static void main(String[] args) {
      Display display = new Display();
      final Shell shell = new Shell(display);
      shell.setText("SWT MenuBar Demonstration");
  
      Menu menuBar = new Menu(shell, SWT.BAR);
  
      Menu fileMenu = new Menu(shell, SWT.DROP_DOWN);
      MenuItem fileItem = new MenuItem(menuBar, SWT.CASCADE);
 
      // try switching next two lines, and see what happens!
      fileItem.setText("File");
      fileItem.setMenu(fileMenu);
 
      MenuItem openItem = new MenuItem(fileMenu, SWT.NULL);
      openItem.setText("Open");
      openItem.addSelectionListener(new SelectionAdapter() {
         public void widgetSelected(SelectionEvent event) {
         	System.out.println("Open selected!");
         }
      });
  
      MenuItem exitItem = new MenuItem(fileMenu, SWT.NULL);
      exitItem.setText("Exit");
      exitItem.addSelectionListener(new SelectionAdapter() {
         public void widgetSelected(SelectionEvent event) {
            shell.close();
         }
      });
       
      shell.setSize(200, 200);
      shell.setMenuBar(menuBar);
      shell.open();
       
      while (!shell.isDisposed()) {
         if (!display.readAndDispatch()) {
            display.sleep();
         }
      }
   }
}