本文整理汇总了Java中org.eclipse.swt.SWT.POP_UP属性的典型用法代码示例。如果您正苦于以下问题:Java SWT.POP_UP属性的具体用法?Java SWT.POP_UP怎么用?Java SWT.POP_UP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.swt.SWT
的用法示例。
在下文中一共展示了SWT.POP_UP属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createWildCardMenu
/**
* Apply a wildcard popup menu to the text. Wildcards a displayed as "[TEXT]" and represent replaceable parameters.
*
* @param text The control to append the menu
* @param wildcards The wildcards to add to the menu
* @param labels The labels for the menuitems
*/
private static void createWildCardMenu(final Text text, String[] wildcards, String[] labels) {
/* Both arrays need to have the same size */
if (wildcards.length != labels.length)
return;
Menu wildCardMenu = new Menu(text);
/* Foreach wildcards */
for (int a = 0; a < wildcards.length; a++) {
final String wildcard = wildcards[a];
MenuItem menuItem = new MenuItem(wildCardMenu, SWT.POP_UP);
menuItem.setText(labels[a]);
if (!GUI.isMac())
// menuItem.setImage(PaintShop.iconBackward);
menuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
text.insert(wildcard);
}
});
}
text.setMenu(wildCardMenu);
}
示例2: initTray
private void initTray() {
tray = display.getSystemTray();
if (tray != null) {
TrayItem trayItem = new TrayItem(tray, SWT.NONE);
trayItem.setImage(ImageUtils.getImage(Images.UNBLOCKED));
trayItem.setToolTipText(APP_NAME);
final Menu trayMenu = new Menu(getShell(), SWT.POP_UP);
MenuItem trayMenuItem = new MenuItem(trayMenu, SWT.PUSH);
trayMenuItem.setText(resourceBundle.getString("exit"));
trayMenuItem.addListener(SWT.Selection, event -> {
if (settings.isConfirmExit()) {
getShell().forceActive();
}
getShell().close();
});
trayItem.addListener(SWT.MenuDetect, event -> trayMenu.setVisible(true));
ToolTip tip = new ToolTip(getShell(), SWT.BALLOON | SWT.ICON_WARNING);
tip.setText(APP_NAME);
tip.setAutoHide(true);
tip.setVisible(false);
trayItem.setToolTip(tip);
}
}
示例3: openPopupMenu
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);
}
示例4: newMItem
private MenuItem newMItem(Menu parent, Command cmd, int style) {
MenuItem item = installSystemMenu(cmd);
if (item != null)
return item; // is a special Mac OS menu
item = new MenuItem(parent, style);
item.setData(cmd);
char equivalent = cmd.getKeyEquiv();
String name = cmd.getMenuName();
if (equivalent != 0 && style != SWT.POP_UP) {
if (!Application.isMac()) {
item.setAccelerator(SWT.CTRL + equivalent);
name += " \tCtrl+" + equivalent;
} else {
item.setAccelerator(SWT.COMMAND + equivalent);
}
// updateAccelerator(item, name, equivalent, false);
item.setText(name);
} else {
item.setText(name);
}
item.addSelectionListener(this);
if (!isMac && cmd.getImage() != null) {
Image img = PaintShop.getImage(cmd.getImage());
if (img != null)
item.setImage(img);
}
registerMenuItem(item);
return item;
}
示例5: createSortMenu
protected void createSortMenu(String menuNames[]) {
if (table == null)
return;
sortMenu = new Menu(table.getShell(), SWT.POP_UP);
for (int x = 0; x < menuNames.length; x++) {
MenuItem item = new MenuItem(sortMenu, SWT.PUSH);
Integer ID = x;
item.setData(ID);
item.setText(menuNames[x]);
item.addSelectionListener(this);
}
table.setMenu(sortMenu);
}
示例6: openPopupMenu
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);
}