/** * Creates all the items located in the Search submenu and associate all the menu items with their * appropriate functions. * * @param menuBar Menu the <code>Menu</code> that file contain the Search submenu. */ private void createSearchMenu(Menu menuBar) { // Search menu. MenuItem item = new MenuItem(menuBar, SWT.CASCADE); item.setText(resMessages.getString("Search_menu_title")); Menu searchMenu = new Menu(shell, SWT.DROP_DOWN); item.setMenu(searchMenu); // Search -> Find... item = new MenuItem(searchMenu, SWT.NULL); item.setText(resMessages.getString("Find")); item.setAccelerator(SWT.MOD1 + 'F'); item.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { searchDialog.setMatchCase(false); searchDialog.setMatchWord(false); searchDialog.setSearchDown(true); searchDialog.setSearchString(""); searchDialog.setSelectedSearchArea(0); searchDialog.open(); } }); // Search -> Find Next item = new MenuItem(searchMenu, SWT.NULL); item.setText(resMessages.getString("Find_next")); item.setAccelerator(SWT.F3); item.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { searchDialog.open(); } }); }
/** * Creates the Other... menu item * * @param menu the menu to add the item to */ private void createOtherMenuItem(final Menu menu) { final IFileRevision fileResource = getFileRevision(); if (fileResource == null) { return; } new MenuItem(menu, SWT.SEPARATOR); final MenuItem menuItem = new MenuItem(menu, SWT.PUSH); menuItem.setText(TeamUIMessages.LocalHistoryPage_OpenWithMenu_Other); Listener listener = new Listener() { public void handleEvent(Event event) { switch (event.type) { case SWT.Selection: EditorSelectionDialog dialog = new EditorSelectionDialog(menu.getShell()); dialog.setMessage( NLS.bind( TeamUIMessages.LocalHistoryPage_OpenWithMenu_OtherDialogDescription, fileResource.getName())); if (dialog.open() == Window.OK) { IEditorDescriptor editor = dialog.getSelectedEditor(); if (editor != null) { openEditor(editor, editor.isOpenExternal()); } } break; } } }; menuItem.addListener(SWT.Selection, listener); }
/** * Creates the menu item for the editor descriptor. * * @param menu the menu to add the item to * @param descriptor the editor descriptor, or null for the system editor * @param preferredEditor the descriptor of the preferred editor, or <code>null</code> */ private MenuItem createMenuItem( Menu menu, final IEditorDescriptor descriptor, final IEditorDescriptor preferredEditor) { // XXX: Would be better to use bold here, but SWT does not support it. final MenuItem menuItem = new MenuItem(menu, SWT.RADIO); boolean isPreferred = preferredEditor != null && descriptor.getId().equals(preferredEditor.getId()); menuItem.setSelection(isPreferred); menuItem.setText(descriptor.getLabel()); Image image = getImage(descriptor); if (image != null) { menuItem.setImage(image); } Listener listener = new Listener() { public void handleEvent(Event event) { switch (event.type) { case SWT.Selection: if (menuItem.getSelection()) { openEditor(descriptor, false); } break; } } }; menuItem.addListener(SWT.Selection, listener); return menuItem; }
/** * Creates all the items located in the Help submenu and associate all the menu items with their * appropriate functions. * * @param menuBar Menu the <code>Menu</code> that file contain the Help submenu. */ private void createHelpMenu(Menu menuBar) { // Help Menu MenuItem item = new MenuItem(menuBar, SWT.CASCADE); item.setText(resMessages.getString("Help_menu_title")); Menu menu = new Menu(shell, SWT.DROP_DOWN); item.setMenu(menu); // Help -> About Text Editor MenuItem subItem = new MenuItem(menu, SWT.NULL); subItem.setText(resMessages.getString("About")); subItem.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { MessageBox box = new MessageBox(shell, SWT.NONE); box.setText(resMessages.getString("About_1") + shell.getText()); box.setMessage(shell.getText() + resMessages.getString("About_2")); box.open(); } }); }
/** * Creates all the items located in the Sort cascading submenu and associate all the menu items * with their appropriate functions. * * @return Menu The cascading menu with all the sort menu items on it. */ private Menu createSortMenu() { Menu submenu = new Menu(shell, SWT.DROP_DOWN); MenuItem subitem; for (int i = 0; i < columnNames.length; i++) { subitem = new MenuItem(submenu, SWT.NULL); subitem.setText(columnNames[i]); final int column = i; subitem.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { sort(column); } }); } return submenu; }
public void createDefaultMenuItem(Menu menu, final IFileRevision revision) { final MenuItem menuItem = new MenuItem(menu, SWT.RADIO); menuItem.setSelection(Utils.getDefaultEditor(revision) == null); menuItem.setText(TeamUIMessages.LocalHistoryPage_OpenWithMenu_DefaultEditorDescription); Listener listener = new Listener() { public void handleEvent(Event event) { switch (event.type) { case SWT.Selection: if (menuItem.getSelection()) { openEditor(Utils.getDefaultEditor(revision), false); } break; } } }; menuItem.addListener(SWT.Selection, listener); }
public ArchiveView(final ArchiveHandler archiveHandler, ListStore<Device> deviceStore) { this.archiveHandler = archiveHandler; deviceStore.addStoreHandlers(deviceStoreHandlers); this.deviceStore = deviceStore; DeviceProperties deviceProperties = GWT.create(DeviceProperties.class); deviceCombo = new ComboBox<Device>(deviceStore, deviceProperties.label()); // Element that displays the current track color styleButtonTrackColor = new TextButton(); styleButtonTrackColor .getElement() .getStyle() .setProperty("backgroundColor", "#".concat(style.DEFAULT_COLOR)); styleButtonTrackColor.getElement().getStyle().setCursor(Style.Cursor.TEXT); // Menu with the small palette smallColorMenu = new ExtColorMenu(ArchiveStyle.COLORS, ArchiveStyle.COLORS); smallColorMenu.setColor(ArchiveStyle.DEFAULT_COLOR); smallColorMenu .getPalette() .addValueChangeHandler( new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { style.setTrackColor(event.getValue()); smallColorMenu.hide(true); fullColorMenu.getPalette().setValue("", false); styleButtonTrackColor .getElement() .getStyle() .setProperty("backgroundColor", "#".concat(style.getTrackColor())); } }); // Menu with the complete palette fullColorMenu = new ColorMenu(); fullColorMenu .getPalette() .addValueChangeHandler( new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { style.setTrackColor(event.getValue()); fullColorMenu.hide(true); smallColorMenu.getPalette().setValue("", false); styleButtonTrackColor .getElement() .getStyle() .setProperty("backgroundColor", "#".concat(style.getTrackColor())); } }); // Markers routeMarkersType = new Menu(); for (Object[] obj : new Object[][] { {i18n.noMarkers(), null}, {i18n.standardMarkers(), PositionIconType.iconArchive}, {i18n.reducedMarkers(), PositionIconType.dotArchive} }) { CheckMenuItem item = new CheckMenuItem((String) obj[0]); final PositionIconType iconType = (PositionIconType) obj[1]; item.setGroup("markers"); item.setChecked( iconType == ApplicationContext.getInstance().getUserSettings().getArchiveMarkerType()); if (item.isChecked()) { style.setIconType(iconType); } item.addSelectionHandler( new SelectionHandler<Item>() { @Override public void onSelection(SelectionEvent<Item> event) { style.setIconType(iconType); archiveHandler.onChangeArchiveMarkerType(iconType); } }); routeMarkersType.add(item); } devicesTabs = new TabPanel(GWT.<TabPanel.TabPanelAppearance>create(BlueTabPanelBottomAppearance.class)); archivePanels = new HashMap<Long, ArchivePanel>(); uiBinder.createAndBindUi(this); markersMenu.setText(i18n.overlayType(UserSettings.OverlayType.MARKERS)); // Initialize with current time long min = 60 * 1000; Date now = new Date(); Date to = new Date(((now.getTime() + 15 * min) / (15 * min)) * 15 * min); Date from = new Date(to.getTime() - 60 * min); fromDate.setValue(from); fromTime.setValue(from); toDate.setValue(to); toTime.setValue(to); }
/** * Creates all items located in the popup menu and associates all the menu items with their * appropriate functions. * * @return Menu The created popup menu. */ private Menu createPopUpMenu() { Menu popUpMenu = new Menu(shell, SWT.POP_UP); /** Adds a listener to handle enabling and disabling some items in the Edit submenu. */ popUpMenu.addMenuListener( new MenuAdapter() { @Override public void menuShown(MenuEvent e) { Menu menu = (Menu) e.widget; MenuItem[] items = menu.getItems(); int count = table.getSelectionCount(); items[2].setEnabled(count != 0); // edit items[3].setEnabled(count != 0); // copy items[4].setEnabled(copyBuffer != null); // paste items[5].setEnabled(count != 0); // delete items[7].setEnabled(table.getItemCount() != 0); // find } }); // New MenuItem item = new MenuItem(popUpMenu, SWT.PUSH); item.setText(resAddressBook.getString("Pop_up_new")); item.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { newEntry(); } }); new MenuItem(popUpMenu, SWT.SEPARATOR); // Edit item = new MenuItem(popUpMenu, SWT.PUSH); item.setText(resAddressBook.getString("Pop_up_edit")); item.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { TableItem[] items = table.getSelection(); if (items.length == 0) return; editEntry(items[0]); } }); // Copy item = new MenuItem(popUpMenu, SWT.PUSH); item.setText(resAddressBook.getString("Pop_up_copy")); item.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { TableItem[] items = table.getSelection(); if (items.length == 0) return; copyBuffer = new String[table.getColumnCount()]; for (int i = 0; i < copyBuffer.length; i++) { copyBuffer[i] = items[0].getText(i); } } }); // Paste item = new MenuItem(popUpMenu, SWT.PUSH); item.setText(resAddressBook.getString("Pop_up_paste")); item.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (copyBuffer == null) return; TableItem item = new TableItem(table, SWT.NONE); item.setText(copyBuffer); isModified = true; } }); // Delete item = new MenuItem(popUpMenu, SWT.PUSH); item.setText(resAddressBook.getString("Pop_up_delete")); item.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { TableItem[] items = table.getSelection(); if (items.length == 0) return; items[0].dispose(); isModified = true; } }); new MenuItem(popUpMenu, SWT.SEPARATOR); // Find... item = new MenuItem(popUpMenu, SWT.PUSH); item.setText(resAddressBook.getString("Pop_up_find")); item.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { searchDialog.open(); } }); return popUpMenu; }
/** * Creates all the items located in the Edit submenu and associate all the menu items with their * appropriate functions. * * @param menuBar Menu the <code>Menu</code> that file contain the Edit submenu. * @see #createSortMenu() */ private MenuItem createEditMenu(Menu menuBar) { // Edit menu. MenuItem item = new MenuItem(menuBar, SWT.CASCADE); item.setText(resAddressBook.getString("Edit_menu_title")); Menu menu = new Menu(shell, SWT.DROP_DOWN); item.setMenu(menu); /** Add a listener to handle enabling and disabling some items in the Edit submenu. */ menu.addMenuListener( new MenuAdapter() { @Override public void menuShown(MenuEvent e) { Menu menu = (Menu) e.widget; MenuItem[] items = menu.getItems(); int count = table.getSelectionCount(); items[0].setEnabled(count != 0); // edit items[1].setEnabled(count != 0); // copy items[2].setEnabled(copyBuffer != null); // paste items[3].setEnabled(count != 0); // delete items[5].setEnabled(table.getItemCount() != 0); // sort } }); // Edit -> Edit MenuItem subItem = new MenuItem(menu, SWT.PUSH); subItem.setText(resAddressBook.getString("Edit")); subItem.setAccelerator(SWT.MOD1 + 'E'); subItem.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { TableItem[] items = table.getSelection(); if (items.length == 0) return; editEntry(items[0]); } }); // Edit -> Copy subItem = new MenuItem(menu, SWT.NONE); subItem.setText(resAddressBook.getString("Copy")); subItem.setAccelerator(SWT.MOD1 + 'C'); subItem.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { TableItem[] items = table.getSelection(); if (items.length == 0) return; copyBuffer = new String[table.getColumnCount()]; for (int i = 0; i < copyBuffer.length; i++) { copyBuffer[i] = items[0].getText(i); } } }); // Edit -> Paste subItem = new MenuItem(menu, SWT.NONE); subItem.setText(resAddressBook.getString("Paste")); subItem.setAccelerator(SWT.MOD1 + 'V'); subItem.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (copyBuffer == null) return; TableItem item = new TableItem(table, SWT.NONE); item.setText(copyBuffer); isModified = true; } }); // Edit -> Delete subItem = new MenuItem(menu, SWT.NONE); subItem.setText(resAddressBook.getString("Delete")); subItem.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { TableItem[] items = table.getSelection(); if (items.length == 0) return; items[0].dispose(); isModified = true; } }); new MenuItem(menu, SWT.SEPARATOR); // Edit -> Sort(Cascade) subItem = new MenuItem(menu, SWT.CASCADE); subItem.setText(resAddressBook.getString("Sort")); Menu submenu = createSortMenu(); subItem.setMenu(submenu); return item; }
/** * Creates all the items located in the File submenu and associate all the menu items with their * appropriate functions. * * @param menuBar Menu the <code>Menu</code> that file contain the File submenu. */ private void createFileMenu(Menu menuBar) { // File menu. MenuItem item = new MenuItem(menuBar, SWT.CASCADE); item.setText(resAddressBook.getString("File_menu_title")); Menu menu = new Menu(shell, SWT.DROP_DOWN); item.setMenu(menu); /** Adds a listener to handle enabling and disabling some items in the Edit submenu. */ menu.addMenuListener( new MenuAdapter() { @Override public void menuShown(MenuEvent e) { Menu menu = (Menu) e.widget; MenuItem[] items = menu.getItems(); items[1].setEnabled(table.getSelectionCount() != 0); // edit contact items[5].setEnabled((file != null) && isModified); // save items[6].setEnabled(table.getItemCount() != 0); // save as } }); // File -> New Contact MenuItem subItem = new MenuItem(menu, SWT.NONE); subItem.setText(resAddressBook.getString("New_contact")); subItem.setAccelerator(SWT.MOD1 + 'N'); subItem.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { newEntry(); } }); subItem = new MenuItem(menu, SWT.NONE); subItem.setText(resAddressBook.getString("Edit_contact")); subItem.setAccelerator(SWT.MOD1 + 'E'); subItem.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { TableItem[] items = table.getSelection(); if (items.length == 0) return; editEntry(items[0]); } }); new MenuItem(menu, SWT.SEPARATOR); // File -> New Address Book subItem = new MenuItem(menu, SWT.NONE); subItem.setText(resAddressBook.getString("New_address_book")); subItem.setAccelerator(SWT.MOD1 + 'B'); subItem.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (closeAddressBook()) { newAddressBook(); } } }); // File -> Open subItem = new MenuItem(menu, SWT.NONE); subItem.setText(resAddressBook.getString("Open_address_book")); subItem.setAccelerator(SWT.MOD1 + 'O'); subItem.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (closeAddressBook()) { openAddressBook(); } } }); // File -> Save. subItem = new MenuItem(menu, SWT.NONE); subItem.setText(resAddressBook.getString("Save_address_book")); subItem.setAccelerator(SWT.MOD1 + 'S'); subItem.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { save(); } }); // File -> Save As. subItem = new MenuItem(menu, SWT.NONE); subItem.setText(resAddressBook.getString("Save_book_as")); subItem.setAccelerator(SWT.MOD1 + 'A'); subItem.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { saveAs(); } }); new MenuItem(menu, SWT.SEPARATOR); // File -> Exit. subItem = new MenuItem(menu, SWT.NONE); subItem.setText(resAddressBook.getString("Exit")); subItem.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { shell.close(); } }); }
/* * (non-Javadoc) * * @see org.eclipse.jface.action.ContributionItem#update(java.lang.String) */ public void update(String id) { if (widget != null) { if (widget instanceof MenuItem) { MenuItem item = (MenuItem) widget; String text = label; if (text == null) { if (command != null) { try { text = command.getCommand().getName(); } catch (NotDefinedException e) { WorkbenchPlugin.log( "Update item failed " //$NON-NLS-1$ + getId(), e); } } } // TODO: [bm] key bindings // text = updateMnemonic(text); // // String keyBindingText = null; // if (command != null) { // TriggerSequence[] bindings = bindingService // .getActiveBindingsFor(command); // if (bindings.length > 0) { // keyBindingText = bindings[0].format(); // } // } // if (text != null) { // if (keyBindingText == null) { item.setText(text); // } else { // item.setText(text + '\t' + keyBindingText); // } // } updateIcons(); if (item.getSelection() != checkedState) { item.setSelection(checkedState); } boolean shouldBeEnabled = isEnabled(); if (item.getEnabled() != shouldBeEnabled) { item.setEnabled(shouldBeEnabled); } } else if (widget instanceof ToolItem) { ToolItem item = (ToolItem) widget; if (icon != null) { updateIcons(); } else if (label != null) { item.setText(label); } if (tooltip != null) item.setToolTipText(tooltip); else { String text = label; if (text == null) { if (command != null) { try { text = command.getCommand().getName(); } catch (NotDefinedException e) { WorkbenchPlugin.log( "Update item failed " //$NON-NLS-1$ + getId(), e); } } } if (text != null) { item.setToolTipText(text); } } if (item.getSelection() != checkedState) { item.setSelection(checkedState); } boolean shouldBeEnabled = isEnabled(); if (item.getEnabled() != shouldBeEnabled) { item.setEnabled(shouldBeEnabled); } } } }
/** Initializes the GUI. */ private void initGUI() { try { getShell() .addDisposeListener( new DisposeListener() { public void widgetDisposed(DisposeEvent evt) { shellWidgetDisposed(evt); } }); getShell() .addControlListener( new ControlAdapter() { public void controlResized(ControlEvent evt) { shellControlResized(evt); } }); getShell() .addControlListener( new ControlAdapter() { public void controlMoved(ControlEvent evt) { shellControlMoved(evt); } }); GridLayout thisLayout = new GridLayout(); this.setLayout(thisLayout); { GridData toolBarLData = new GridData(); toolBarLData.grabExcessHorizontalSpace = true; toolBarLData.horizontalAlignment = GridData.FILL; toolBar = new ToolBar(this, SWT.FLAT); toolBar.setLayoutData(toolBarLData); toolBar.setBackgroundImage(SWTResourceManager.getImage("images/ToolbarBackground.gif")); { newToolItem = new ToolItem(toolBar, SWT.NONE); newToolItem.setImage(SWTResourceManager.getImage("images/new.gif")); newToolItem.setToolTipText("New"); } { openToolItem = new ToolItem(toolBar, SWT.NONE); openToolItem.setToolTipText("Open"); openToolItem.setImage(SWTResourceManager.getImage("images/open.gif")); openToolItem.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { openToolItemWidgetSelected(evt); } }); } { saveToolItem = new ToolItem(toolBar, SWT.NONE); saveToolItem.setToolTipText("Save"); saveToolItem.setImage(SWTResourceManager.getImage("images/save.gif")); } } { clientArea = new Composite(this, SWT.NONE); GridData clientAreaLData = new GridData(); clientAreaLData.grabExcessHorizontalSpace = true; clientAreaLData.grabExcessVerticalSpace = true; clientAreaLData.horizontalAlignment = GridData.FILL; clientAreaLData.verticalAlignment = GridData.FILL; clientArea.setLayoutData(clientAreaLData); clientArea.setLayout(null); } { statusArea = new Composite(this, SWT.NONE); GridLayout statusAreaLayout = new GridLayout(); statusAreaLayout.makeColumnsEqualWidth = true; statusAreaLayout.horizontalSpacing = 0; statusAreaLayout.marginHeight = 0; statusAreaLayout.marginWidth = 0; statusAreaLayout.verticalSpacing = 0; statusAreaLayout.marginLeft = 3; statusAreaLayout.marginRight = 3; statusAreaLayout.marginTop = 3; statusAreaLayout.marginBottom = 3; statusArea.setLayout(statusAreaLayout); GridData statusAreaLData = new GridData(); statusAreaLData.horizontalAlignment = GridData.FILL; statusAreaLData.grabExcessHorizontalSpace = true; statusArea.setLayoutData(statusAreaLData); statusArea.setBackground(SWTResourceManager.getColor(239, 237, 224)); { statusText = new Label(statusArea, SWT.BORDER); statusText.setText(" Ready"); GridData txtStatusLData = new GridData(); txtStatusLData.horizontalAlignment = GridData.FILL; txtStatusLData.grabExcessHorizontalSpace = true; txtStatusLData.verticalIndent = 3; statusText.setLayoutData(txtStatusLData); } } thisLayout.verticalSpacing = 0; thisLayout.marginWidth = 0; thisLayout.marginHeight = 0; thisLayout.horizontalSpacing = 0; thisLayout.marginTop = 3; this.setSize(474, 312); { menu1 = new Menu(getShell(), SWT.BAR); getShell().setMenuBar(menu1); { fileMenuItem = new MenuItem(menu1, SWT.CASCADE); fileMenuItem.setText("&File"); { fileMenu = new Menu(fileMenuItem); { newFileMenuItem = new MenuItem(fileMenu, SWT.PUSH); newFileMenuItem.setText("&New"); newFileMenuItem.setImage(SWTResourceManager.getImage("images/new.gif")); } { openFileMenuItem = new MenuItem(fileMenu, SWT.PUSH); openFileMenuItem.setText("&Open"); openFileMenuItem.setImage(SWTResourceManager.getImage("images/open.gif")); openFileMenuItem.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { openFileMenuItemWidgetSelected(evt); } }); } { closeFileMenuItem = new MenuItem(fileMenu, SWT.CASCADE); closeFileMenuItem.setText("Close"); } { fileMenuSep1 = new MenuItem(fileMenu, SWT.SEPARATOR); } { saveFileMenuItem = new MenuItem(fileMenu, SWT.PUSH); saveFileMenuItem.setText("&Save"); saveFileMenuItem.setImage(SWTResourceManager.getImage("images/save.gif")); saveFileMenuItem.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { saveFileMenuItemWidgetSelected(evt); } }); } { fileMenuSep2 = new MenuItem(fileMenu, SWT.SEPARATOR); } { exitMenuItem = new MenuItem(fileMenu, SWT.CASCADE); exitMenuItem.setText("E&xit"); exitMenuItem.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { exitMenuItemWidgetSelected(evt); } }); } fileMenuItem.setMenu(fileMenu); } } { helpMenuItem = new MenuItem(menu1, SWT.CASCADE); helpMenuItem.setText("&Help"); { helpMenu = new Menu(helpMenuItem); { aboutMenuItem = new MenuItem(helpMenu, SWT.CASCADE); aboutMenuItem.setText("&About"); aboutMenuItem.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { aboutMenuItemWidgetSelected(evt); } }); } helpMenuItem.setMenu(helpMenu); } } } } catch (Exception e) { e.printStackTrace(); } }