本文整理汇总了Java中org.eclipse.swt.SWT.ARROW属性的典型用法代码示例。如果您正苦于以下问题:Java SWT.ARROW属性的具体用法?Java SWT.ARROW怎么用?Java SWT.ARROW使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.swt.SWT
的用法示例。
在下文中一共展示了SWT.ARROW属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: widgetSelected
/**
* Handle selection events.
*/
public void widgetSelected(SelectionEvent event) {
/**
* A selection event will be fired when a drop down tool
* item is selected in the main area and in the drop
* down arrow. Examine the event detail to determine
* where the widget was selected.
*/
if (event.detail == SWT.ARROW) {
/*
* The drop down arrow was selected.
*/
if (visible) {
// Hide the menu to give the Arrow the appearance of being a toggle button.
setMenuVisible(false);
} else {
// Position the menu below and vertically aligned with the the drop down tool button.
final ToolItem toolItem = (ToolItem) event.widget;
final ToolBar toolBar = toolItem.getParent();
Rectangle toolItemBounds = toolItem.getBounds();
Point point = toolBar.toDisplay(new Point(toolItemBounds.x, toolItemBounds.y));
menu.setLocation(point.x, point.y + toolItemBounds.height);
setMenuVisible(true);
}
} else {
/*
* Main area of drop down tool item selected.
* An application would invoke the code to perform the action for the tool item.
*/
}
}
示例2: execute
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
// Sanity check.
if (null == event) {
return null;
}
// Class check.
if (!(event.getTrigger() instanceof Event)) {
return null;
}
final Event eventWidget = (Event) event.getTrigger();
// Makes sure event came from a ToolItem.
if (!(eventWidget.widget instanceof ToolItem)) {
return null;
}
final ToolItem toolItem = (ToolItem) eventWidget.widget;
// Creates fake selection event.
final Event newEvent = new Event();
newEvent.button = 1;
newEvent.widget = toolItem;
newEvent.detail = SWT.ARROW;
newEvent.x = toolItem.getBounds().x;
newEvent.y = toolItem.getBounds().y + toolItem.getBounds().height;
// Dispatches the event.
toolItem.notifyListeners(SWT.Selection, newEvent);
return null;
}