当前位置: 首页>>代码示例>>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;未经允许,请勿转载。