Bug 338825 Rename Display.getAppMenuBar() to getMenuBar().
examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet348.java
shell.addDisposeListener(new DisposeListener() {
			public void widgetDisposed(DisposeEvent e) {
				Display d = Display.getCurrent();
				Menu bar = d.getAppMenuBar();
				boolean hasAppMenuBar = (bar != null);
				if (!hasAppMenuBar) {
					shell.getMenuBar().dispose();
					Shell[] shells = d.getShells();
					if ((shells.length == 1) && (shells[0] == shell)) {
						if (!d.isDisposed()) d.dispose();
					}
				}					
			}
		});
		
		return shell;
	}
	
	public static void main(String[] args) {
		final Display display = new Display();
		
		Shell shell = createShell();
		shell.open();
		
		while (!display.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
	}
}