本文整理汇总了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);
}
示例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);
}
}
示例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);
}
}
示例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);
}