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


Java MenuItem.setAccelerator方法代碼示例

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


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

示例1: 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

示例2: addMenuItem

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private MenuItem addMenuItem(Menu menu, String text, int accelerator,
		Object data, SelectionListener listener) {
	MenuItem item = new MenuItem(menu, SWT.NONE);
	item.setText(text);
	item.addSelectionListener(listener);
	if (accelerator != SWT.NONE)
		item.setAccelerator(accelerator);
	item.setData(data);
	return item;
}
 
開發者ID:juanerasmoe,項目名稱:pmTrans,代碼行數:11,代碼來源:BarManager.java

示例3: addMenuItem

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private MenuItem addMenuItem(Menu menu, String text, int accelerator,
		SelectionListener listener) {
	MenuItem item = addMenuItem(menu, text, listener);
	if (accelerator != SWT.NONE)
		item.setAccelerator(accelerator);
	return item;
}
 
開發者ID:juanerasmoe,項目名稱:pmTrans,代碼行數:8,代碼來源:MenuManager.java

示例4: updateAccelerator

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private void updateAccelerator(MenuItem item, String itemText,
		char newAccelerator) {
	itemText += " \t Ctrl+"
			+ (newAccelerator == ' ' ? "[space]" : newAccelerator);
	int acc = SWT.MOD1
			+ (newAccelerator == ' ' ? SWT.SPACE : newAccelerator);
	item.setText(itemText);
	item.setAccelerator(acc);
}
 
開發者ID:juanerasmoe,項目名稱:pmTrans,代碼行數:10,代碼來源:MenuManager.java

示例5: setAccelerator

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
/**
 * Helper method to set a keyboard accelerator for a MenuItem. If kbInfo is SWT.NONE, no accelerator will be set.
 * @param menu SWT MenuItem
 * @param kbInfo KeyBindingInfo object, which contains the SWT accelerator value and its display name
 */
private static void setAccelerator(final MenuItem menu, final KeyBindingInfo kbInfo)
{
	if ( menu.isDisposed()){
		return;
	}
    if(kbInfo.accelerator != SWT.NONE)
    {
        menu.setAccelerator(kbInfo.accelerator);

        // SWT on OS X now uses native drawing
        if(!Constants.isOSX && !menu.getText().endsWith(kbInfo.name))
            menu.setText(menu.getText() + kbInfo.name);
    }
}
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:20,代碼來源:KeyBindings.java

示例6: addItem

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private void addItem(Menu viewmenu, TabPanel tab, char accel) {
	MenuItem engineItem = new MenuItem(viewmenu, SWT.PUSH);
	engineItem.setText("&"+tab.getLabel()+"\tCTRL+"+accel);
	engineItem.setAccelerator(SWT.CTRL + accel);
	engineItem.addSelectionListener(tab);
}
 
開發者ID:arisona,項目名稱:ether,代碼行數:7,代碼來源:Soundium.java

示例7: ContextMenu

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
public ContextMenu(final EarthquakeBulletinGui gui) {
	final Table table = ResultsTable.this.getTableViewer().getTable();
	menu = new Menu(table);

	// Show map...
	showMapMenuItem = new MenuItem(menu, SWT.PUSH);
	showMapMenuItem.setText(Messages.get(LBL_MENU_ITEM_SHOW_MAP));
	showMapMenuItem.addListener(SWT.Selection, new ShowMapListener(gui));
	menu.setDefaultItem(showMapMenuItem);

	new MenuItem(menu, SWT.SEPARATOR);

	// Open in browser...
	openBrowserMenuItem = new MenuItem(menu, SWT.PUSH);
	openBrowserMenuItem.setText(Messages.get(LBL_MENU_ITEM_OPEN_BROWSER));
	openBrowserMenuItem.addSelectionListener(new OpenInBrowserSelectionListener(gui));

	// Copy link...
	copyLinkMenuItem = new MenuItem(menu, SWT.PUSH);
	copyLinkMenuItem.setText(Messages.get(LBL_MENU_ITEM_COPY_LINK));
	copyLinkMenuItem.addSelectionListener(new CopyLinkSelectionListener(gui));

	new MenuItem(menu, SWT.SEPARATOR);

	// Google Maps Popup...
	googleMapsPopupMenuItem = new MenuItem(menu, SWT.PUSH);
	googleMapsPopupMenuItem.setText(Messages.get(LBL_MENU_ITEM_GOOGLE_MAPS_POPUP));
	googleMapsPopupMenuItem.addSelectionListener(new GoogleMapsPopupSelectionListener(gui));

	// Google Maps in browser...
	googleMapsBrowserMenuItem = new MenuItem(menu, SWT.PUSH);
	googleMapsBrowserMenuItem.setText(Messages.get(LBL_MENU_ITEM_GOOGLE_MAPS_BROWSER));
	googleMapsBrowserMenuItem.addSelectionListener(new GoogleMapsBrowserSelectionListener(gui));

	new MenuItem(menu, SWT.SEPARATOR);

	exportCsvMenuItem = new MenuItem(menu, SWT.PUSH);
	exportCsvMenuItem.setText(Messages.get(LBL_MENU_ITEM_EXPORT_CSV) + SwtUtils.getMod1ShortcutLabel(SwtUtils.KEY_SAVE));
	exportCsvMenuItem.addSelectionListener(new ExportCsvSelectionListener(gui));
	exportCsvMenuItem.setAccelerator(SWT.MOD1 | SwtUtils.KEY_SAVE);

	table.addMenuDetectListener(new ResultsTableContextMenuDetectListener(ResultsTable.this));
}
 
開發者ID:Albertus82,項目名稱:EarthquakeBulletin,代碼行數:44,代碼來源:ResultsTable.java


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