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


Java Menu.setLocation方法代碼示例

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


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

示例1: openPopupMenu

import org.eclipse.swt.widgets.Menu; //導入方法依賴的package包/類
protected void openPopupMenu(NodeType[] availableTypes, final AvroNode targetNode, final AvroContext context) {
	
	Shell shell = Display.getCurrent().getActiveShell();
	final Menu menu = new Menu(shell, SWT.POP_UP);
	for (NodeType availableType : availableTypes) {
		final NodeType type = availableType;
		MenuItem item = new MenuItem(menu, SWT.PUSH);
		item.setText(type.getDisplayLabel());
		item.addListener(SWT.Selection, new Listener() {
			public void handleEvent(Event e) {
				menu.dispose();
				IEditCommand cmd = context.getService(IEditCommandFactory.class)
						.createAddElementCommand(targetNode, type, getNotifications());
				context.getService(ICommandExecutor.class).execute(cmd);
			}
		});
	}
       
	Point location = MouseInfo.getPointerInfo().getLocation();
	int x = location.x;
	int y = location.y;
       menu.setLocation(x, y);
       menu.setVisible(true);
       
}
 
開發者ID:Talend,項目名稱:avro-schema-editor,代碼行數:26,代碼來源:AddElementAction.java

示例2: runWithEvent

import org.eclipse.swt.widgets.Menu; //導入方法依賴的package包/類
@Override
public void runWithEvent(final Event event) {
	if (event.widget instanceof ToolItem) {
		final ToolItem toolItem = (ToolItem) event.widget;
		final Control control = toolItem.getParent();
		@SuppressWarnings("hiding")
		final Menu menu = getMenu(control);
		final Rectangle bounds = toolItem.getBounds();
		final Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
		menu.setLocation(control.toDisplay(topLeft));
		menu.setVisible(true);
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:14,代碼來源:DropDownAction.java

示例3: runWithEvent

import org.eclipse.swt.widgets.Menu; //導入方法依賴的package包/類
@Override
public void runWithEvent(Event event) {
	if (event.widget instanceof ToolItem) {
		final ToolItem toolItem = (ToolItem) event.widget;
		final Control control = toolItem.getParent();
		final Menu menu = getMenuCreator().getMenu(control);

		final Rectangle bounds = toolItem.getBounds();
		final Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
		menu.setLocation(control.toDisplay(topLeft));
		menu.setVisible(true);
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:14,代碼來源:ShowHistoryAction.java

示例4: openPopupMenu

import org.eclipse.swt.widgets.Menu; //導入方法依賴的package包/類
protected void openPopupMenu(List<DragAndDropPolicy.Action> availableActions,
		final AvroNode sourceNode, final AvroNode targetNode, final TargetPosition position) {
	
	Shell shell = Display.getCurrent().getActiveShell();
	final Menu menu = new Menu(shell, SWT.POP_UP);
	
	for (DragAndDropPolicy.Action availableAction : availableActions) {
		final DragAndDropPolicy.Action action = availableAction;
		MenuItem item = new MenuItem(menu, SWT.PUSH);
		item.setText(action.getLabel());
		item.addListener(SWT.Selection, new Listener() {
			public void handleEvent(Event e) {
				menu.dispose();
				IEditCommand cmd = context.getService(IEditCommandFactory.class)
						.createDnDElementCommand(action, sourceNode, targetNode, position, Notifications.NOT_REF);					
				if (cmd != null) {	
					context.getService(ICommandExecutor.class).execute(cmd);
				}
			}
		});
	}
       
	java.awt.Point location = MouseInfo.getPointerInfo().getLocation();
	int x = location.x;
	int y = location.y;
       menu.setLocation(x, y);
       menu.setVisible(true);
       
}
 
開發者ID:Talend,項目名稱:avro-schema-editor,代碼行數:30,代碼來源:AvroSchemaViewerDropPolicy.java


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