當前位置: 首頁>>代碼示例>>Java>>正文


Java MenuItem.setImage方法代碼示例

本文整理匯總了Java中org.eclipse.swt.widgets.MenuItem.setImage方法的典型用法代碼示例。如果您正苦於以下問題:Java MenuItem.setImage方法的具體用法?Java MenuItem.setImage怎麽用?Java MenuItem.setImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.swt.widgets.MenuItem的用法示例。


在下文中一共展示了MenuItem.setImage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initDocOverviewMenu

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private void initDocOverviewMenu() {
	Table t = docTableWidget.getPageableTable().getViewer().getTable();
	docOverviewMenu = new Menu(t);
	t.setMenu(docOverviewMenu);
	
	addToCollectionMenuItem = new MenuItem(docOverviewMenu, SWT.PUSH);
	addToCollectionMenuItem.setImage(Images.ADD);
	addToCollectionMenuItem.setText("Add to different collection...");
	
	removeFromCollectionMenuItem = new MenuItem(docOverviewMenu, SWT.PUSH);
	removeFromCollectionMenuItem.setImage(Images.DELETE);
	removeFromCollectionMenuItem.setText("Remove from this collection...");		
	
	deleteDocMenuItem = new MenuItem(docOverviewMenu, SWT.PUSH);
	deleteDocMenuItem.setImage(Images.FOLDER_DELETE);
	deleteDocMenuItem.setText("Delete document...");
	
	duplicateDocMenuItem = new MenuItem(docOverviewMenu, SWT.PUSH);
	duplicateDocMenuItem.setImage(Images.PAGE_COPY);
	duplicateDocMenuItem.setText("Duplicate...");
}
 
開發者ID:Transkribus,項目名稱:TranskribusSwtGui,代碼行數:22,代碼來源:ServerWidget.java

示例2: createMenuItem

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private void createMenuItem(Menu menu, BookmarkId selectedBookmarkId, BookmarkNumber bookmarkNumber) {
	Optional<BookmarkId> bookmarkId = numberedBookmarks.getBookmark(bookmarkNumber);
	final MenuItem menuItem = new MenuItem(menu, SWT.RADIO);
	menuItem.setSelection(bookmarkId.isPresent() ? bookmarkId.get().equals(selectedBookmarkId) : false);
	menuItem.setText(getText(bookmarkId));
	menuItem.setAccelerator('0' + bookmarkNumber.getNumber());
	Image image = getImage(bookmarkNumber, bookmarkId);
	if (image != null) {
		menuItem.setImage(image);
	}
	Listener listener = new Listener() {
		@Override
		public void handleEvent(Event event) {
			switch (event.type) {
			case SWT.Selection:
				if (menuItem.getSelection()) {
					bookmarksService.addNumberedBookmark(selectedBookmarkId, bookmarkNumber);
				}
				break;
			}
		}
	};
	menuItem.addListener(SWT.Selection, listener);
}
 
開發者ID:cchabanois,項目名稱:mesfavoris,代碼行數:25,代碼來源:SetNumberForBookmarkMenu.java

示例3: addMenuItem

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private MenuItem addMenuItem(Menu menu, String text, int accelerator,
		SelectionListener listener, Image icon) {
	MenuItem item = addMenuItem(menu, text, accelerator, listener);
	item.setImage(icon);

	return item;
}
 
開發者ID:juanerasmoe,項目名稱:pmTrans,代碼行數:8,代碼來源:MenuManager.java

示例4: addMenuItem

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
/**
 * Adds an item to the menu shown when
 * {@link #widgetSelected(SelectionEvent)} is invoked.
 *
 * This class does <b>not</b> dispose the given {@link Image}.
 *
 * @param text
 *        the text of the menu item (may be <code>null</code>)
 * @param image
 *        the image for the menu item (may be <code>null</code>)
 * @param toolTipText
 *        tool tip text to use for the tool item when this menu item is the
 *        selected item (may be <code>null</code>)
 * @param menuItemStyle
 *        style for the {@link MenuItem}
 * @param menuSelectedHandler
 *        handles when the menu is selected (must not be <code>null</code>)
 * @return the {@link MenuItem} added so the caller can listen for events,
 *         etc. (never <code>null</code>)
 */
public MenuItem addMenuItem(
    final String text,
    final Image image,
    final String toolTipText,
    final int menuItemStyle,
    final MenuItemSelectedHandler menuSelectedHandler) {
    Check.notNull(menuSelectedHandler, "clickHandler"); //$NON-NLS-1$

    final MenuItem menuItem = new MenuItem(menu, menuItemStyle);
    menuItem.setText(text);
    menuItem.setImage(image);
    menuItem.setData(TOOLTIP_TEXT_WIDGET_DATA_KEY, toolTipText);
    menuItem.setData(MENU_ITEM_SELECTED_HANDLER_WIDGET_DATA_KEY, menuSelectedHandler);

    menuItem.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent event) {
            /*
             * Simply update the tool item with the text, image, and tooltip
             * text from this menu item. The tool item will fire an event
             * the user can handle to detect the switch.
             */
            final MenuItem selected = (MenuItem) event.widget;

            setDefaultToolItem(selected);

            menuSelectedHandler.onMenuItemSelected(menuItem);
        }
    });

    return menuItem;
}
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:53,代碼來源:DropdownToolItemSelectionListener.java

示例5: createItem

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private void createItem(final Menu parent, final int index,
    final ICoverageLaunch launch) {
  final MenuItem item = new MenuItem(parent, SWT.PUSH, index);
  item.setImage(EclEmmaUIPlugin.getImage(EclEmmaUIPlugin.ELCL_DUMP));
  item.setText(LaunchLabelProvider.getLaunchText(launch));
  item.addSelectionListener(new SelectionAdapter() {
    @Override
    public void widgetSelected(SelectionEvent e) {
      DumpExecutionDataHandler.requestDump(launch);
    }
  });
}
 
開發者ID:eclipse,項目名稱:eclemma,代碼行數:13,代碼來源:DumpExecutionDataItems.java

示例6: createItem

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private void createItem(final Menu parent, final int index,
    final ICoverageSession session, final boolean selected,
    final int position, final ISessionManager sm) {
  final MenuItem item = new MenuItem(parent, SWT.RADIO, index);
  item.setImage(EclEmmaUIPlugin.getImage(EclEmmaUIPlugin.ELCL_SESSION));
  item.setText(getLabel(session, position));
  item.setSelection(selected);
  item.addSelectionListener(new SelectionAdapter() {
    @Override
    public void widgetSelected(SelectionEvent e) {
      sm.activateSession(session);
    }
  });
}
 
開發者ID:eclipse,項目名稱:eclemma,代碼行數:15,代碼來源:SelectActiveSessionsItems.java

示例7: createMenu

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
public void createMenu(TGToolBar toolBar, ToolItem item) {
	TGLayout layout = toolBar.getTablature().getViewLayout();
	int style = layout.getStyle();
	
	Menu menu = new Menu(item.getParent().getShell());
	
	MenuItem pageLayout = new MenuItem(menu, SWT.PUSH);
	pageLayout.addSelectionListener(toolBar.createActionProcessor(TGSetPageLayoutAction.NAME));
	pageLayout.setText(toolBar.getText("view.layout.page", (layout instanceof TGLayoutVertical)));
	pageLayout.setImage(toolBar.getIconManager().getLayoutPage());
	
	MenuItem linearLayout = new MenuItem(menu, SWT.PUSH);
	linearLayout.addSelectionListener(toolBar.createActionProcessor(TGSetLinearLayoutAction.NAME));
	linearLayout.setText(toolBar.getText("view.layout.linear", (layout instanceof TGLayoutHorizontal)));
	linearLayout.setImage(toolBar.getIconManager().getLayoutLinear());
	
	MenuItem multitrack = new MenuItem(menu, SWT.PUSH);
	multitrack.addSelectionListener(toolBar.createActionProcessor(TGSetMultitrackViewAction.NAME));
	multitrack.setText(toolBar.getText("view.layout.multitrack", ( (style & TGLayout.DISPLAY_MULTITRACK) != 0 )));
	multitrack.setImage(toolBar.getIconManager().getLayoutMultitrack());
	
	MenuItem scoreEnabled = new MenuItem(menu, SWT.PUSH);
	scoreEnabled.addSelectionListener(toolBar.createActionProcessor(TGSetScoreEnabledAction.NAME));
	scoreEnabled.setText(toolBar.getText("view.layout.score-enabled", ( (style & TGLayout.DISPLAY_SCORE) != 0 )));
	scoreEnabled.setImage(toolBar.getIconManager().getLayoutScore());
	
	MenuItem compact = new MenuItem(menu, SWT.PUSH);
	compact.addSelectionListener(toolBar.createActionProcessor(TGSetCompactViewAction.NAME));
	compact.setText(toolBar.getText("view.layout.compact", ( (style & TGLayout.DISPLAY_COMPACT) != 0 )));
	compact.setImage(toolBar.getIconManager().getLayoutCompact());
	compact.setEnabled((style & TGLayout.DISPLAY_MULTITRACK) == 0 || toolBar.getSong().countTracks() == 1);
	
	Rectangle rect = item.getBounds();
	Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
	
	menu.setLocation(pt.x, pt.y + rect.height);
	menu.setVisible(true);
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:39,代碼來源:TGToolBarSectionLayout.java

示例8: createMenuItem

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private void createMenuItem(TGToolBar toolBar, Menu menu, int velocity, int selection, boolean running) {
	MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
	menuItem.setEnabled(!running);
	menuItem.addSelectionListener(this.createChangeVelocityAction(toolBar, velocity));
	
	String nameKey = getNameKey(velocity);
	if( nameKey != null ) {
		menuItem.setText(toolBar.getText(nameKey, (velocity == selection)));
	}
	Image icon = this.getDynamicIcon(toolBar, velocity);
	if( icon != null ) {
		menuItem.setImage(icon);
	}
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:15,代碼來源:TGToolBarSectionDynamic.java

示例9: createDurationMenuItem

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private void createDurationMenuItem(TGToolBar toolBar, Menu menu, int value, int selection, boolean running) {
	Image icon = this.findDurationIcon(toolBar, value);
	String action = this.findDurationAction(value);
	String nameKey = this.findDurationNameKey(value);
	if( icon != null && action != null && nameKey != null ) {
		MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
		menuItem.setEnabled(!running);
		menuItem.addSelectionListener(toolBar.createActionProcessor(action));
		menuItem.setText(toolBar.getText(nameKey, (value == selection)));
		menuItem.setImage(icon);
	}
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:13,代碼來源:TGToolBarSectionDuration.java

示例10: createMenu

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
public void createMenu(TGToolBar toolBar, ToolItem item) {
	Menu menu = new Menu(item.getParent().getShell());
	
	//--FRETBOARD--
	MenuItem showFretBoard = new MenuItem(menu, SWT.PUSH);
	showFretBoard.addSelectionListener(toolBar.createActionProcessor(TGToggleFretBoardEditorAction.NAME));
	showFretBoard.setImage(toolBar.getIconManager().getFretboard());
	showFretBoard.setText(toolBar.getText("view.show-fretboard", TGFretBoardEditor.getInstance(toolBar.getContext()).isVisible()));

	//--INSTRUMENTS--
	MenuItem showInstruments = new MenuItem(menu, SWT.PUSH);
	showInstruments.addSelectionListener(toolBar.createActionProcessor(TGToggleChannelsDialogAction.NAME));
	showInstruments.setImage(toolBar.getIconManager().getInstruments());
	showInstruments.setText(toolBar.getText("view.show-instruments", (!TGChannelManagerDialog.getInstance(toolBar.getContext()).isDisposed())));

	//--TRANSPORT--
	MenuItem showTransport = new MenuItem(menu, SWT.PUSH);
	showTransport.addSelectionListener(toolBar.createActionProcessor(TGToggleTransportDialogAction.NAME));
	showTransport.setImage(toolBar.getIconManager().getTransport());
	showTransport.setText(toolBar.getText("view.show-transport", (!TGTransportDialog.getInstance(toolBar.getContext()).isDisposed())));
	
	Rectangle rect = item.getBounds();
	Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
	
	menu.setLocation(pt.x, pt.y + rect.height);
	menu.setVisible(true);
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:28,代碼來源:TGToolBarSectionView.java

示例11: createItem

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
MenuItem createItem(Menu parent, int style, Image img, String txt) {
	MenuItem mi = new MenuItem(parent, style);
	mi.setImage(img);
	mi.setText(txt);
	
	return mi;
}
 
開發者ID:Transkribus,項目名稱:TranskribusSwtGui,代碼行數:8,代碼來源:TrpMenuBar.java

示例12: createMenuItem

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
protected MenuItem createMenuItem(String txt, Image img, Event event, Menu menu) {
	MenuItem item = new MenuItem(menu, SWT.NONE);
	item.setText(txt);
	if (img != null)
		item.setImage(img);
	
	SWTUtil.onSelectionEvent(item, (e) -> { sendEvent(event); });
	
	return item;
}
 
開發者ID:Transkribus,項目名稱:TranskribusSwtGui,代碼行數:11,代碼來源:CanvasContextMenu.java

示例13: addItem

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
public MenuItem addItem(String text, Image img) {
MenuItem item = new MenuItem(menu, SWT.PUSH);
      item.setText(text);
      item.setImage(img);
      
      return item;
  }
 
開發者ID:Transkribus,項目名稱:TranskribusSwtGui,代碼行數:8,代碼來源:DropDownButton.java

示例14: createMenuItem

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
public static MenuItem createMenuItem(Menu menu, String text, Image img, int style) {
MenuItem item = new MenuItem(menu, style);
      item.setText(text);
      item.setImage(img);
      
      return item;
  }
 
開發者ID:Transkribus,項目名稱:TranskribusSwtGui,代碼行數:8,代碼來源:SWTUtil.java

示例15: add

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
public MenuItem add(String item, Image image, String toolTipText, int itemStyle, boolean isSelected, Object data) {
			MenuItem menuItem = new MenuItem(menu, itemStyle);
						
//			MenuItem menuItem = new MenuItem(menu, SWT.CHECK);
			menuItem.setData("tooltip", toolTipText);
			menuItem.setText(item);
			if (image != null){
				menuItem.setImage(image);
			}
//			menuItem.setSelection(false);
			menuItem.setSelection(isSelected);
			menuItem.setData(data);
			
			menuItem.addSelectionListener(new SelectionAdapter() {
				@Override
				public void widgetSelected(SelectionEvent event) {
					if (isKeepMenuOpenOnClick()) {
						Display.getDefault().asyncExec(() -> { showMenu(); });
					}
					
					MenuItem selected = (MenuItem) event.widget;
					logger.debug("menuitem selected: "+selected.getData()+" source = "+event.getSource()+ " isselected: "+selected.getSelection());
					
					if ( ( (selected.getStyle() & SWT.RADIO) != SWT.RADIO) || selected.getSelection() ) { // only one selection event for radio menuitem's!!
						selectItem(selected, true);
					}
				}
			});
			
			

			if (selected == null) {
				selectItem(menuItem, false);
			}
			
			return menuItem;
		}
 
開發者ID:Transkribus,項目名稱:TranskribusSwtGui,代碼行數:38,代碼來源:DropDownToolItem.java


注:本文中的org.eclipse.swt.widgets.MenuItem.setImage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。