本文整理匯總了Java中org.eclipse.swt.widgets.ToolItem.setData方法的典型用法代碼示例。如果您正苦於以下問題:Java ToolItem.setData方法的具體用法?Java ToolItem.setData怎麽用?Java ToolItem.setData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.swt.widgets.ToolItem
的用法示例。
在下文中一共展示了ToolItem.setData方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addIconButton
import org.eclipse.swt.widgets.ToolItem; //導入方法依賴的package包/類
public ToolItem addIconButton(ToolBar toolBar, Command cmd) {
final ToolItem item = new ToolItem(toolBar, SWT.PUSH);
String icon = "icons/" + cmd.name().toLowerCase() + ".png";
item.setImage(PaintShop.getImage(icon));
item.setText("");
item.setToolTipText(cmd.getToolTip());
item.setData(cmd);
item.addSelectionListener(this);
return item;
}
示例2: initTaggingToolbar
import org.eclipse.swt.widgets.ToolItem; //導入方法依賴的package包/類
private void initTaggingToolbar() {
boldTagItem = new ToolItem(regionsToolbar, SWT.PUSH);
boldTagItem.setImage(Images.getOrLoad("/icons/text_bold.png"));
boldTagItem.setToolTipText("Tag text as bold");
boldTagItem.setData(TextStyleTag.getBoldTag());
boldTagItem.addSelectionListener(new TagItemListener());
additionalToolItems.add(boldTagItem);
italicTagItem = new ToolItem(regionsToolbar, SWT.PUSH);
italicTagItem.setImage(Images.getOrLoad("/icons/text_italic.png"));
italicTagItem.setToolTipText("Tag as italic");
italicTagItem.setData(TextStyleTag.getItalicTag());
italicTagItem.addSelectionListener(new TagItemListener());
additionalToolItems.add(italicTagItem);
subscriptTagItem = new ToolItem(regionsToolbar, SWT.PUSH);
subscriptTagItem.setImage(Images.getOrLoad("/icons/text_subscript.png"));
subscriptTagItem.setToolTipText("Tag as subscript");
subscriptTagItem.setData(TextStyleTag.getSubscriptTag());
subscriptTagItem.addSelectionListener(new TagItemListener());
additionalToolItems.add(subscriptTagItem);
superscriptTagItem = new ToolItem(regionsToolbar, SWT.PUSH);
superscriptTagItem.setImage(Images.getOrLoad("/icons/text_superscript.png"));
superscriptTagItem.setToolTipText("Tag as superscript");
superscriptTagItem.setData(TextStyleTag.getSuperscriptTag());
superscriptTagItem.addSelectionListener(new TagItemListener());
additionalToolItems.add(superscriptTagItem);
underlinedTagItem = new ToolItem(regionsToolbar, SWT.PUSH);
underlinedTagItem.setImage(Images.getOrLoad("/icons/text_underline.png"));
underlinedTagItem.setToolTipText("Tag as underlined");
underlinedTagItem.setData(TextStyleTag.getUnderlinedTag());
underlinedTagItem.addSelectionListener(new TagItemListener());
additionalToolItems.add(underlinedTagItem);
strikethroughTagItem = new ToolItem(regionsToolbar, SWT.PUSH);
strikethroughTagItem.setImage(Images.getOrLoad("/icons/text_strikethrough.png"));
strikethroughTagItem.setToolTipText("Tag as strikethrough");
strikethroughTagItem.setData(TextStyleTag.getStrikethroughTag());
strikethroughTagItem.addSelectionListener(new TagItemListener());
additionalToolItems.add(strikethroughTagItem);
}