本文整理了Java中org.eclipse.swt.widgets.MenuItem.setImage()
方法的一些代码示例,展示了MenuItem.setImage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem.setImage()
方法的具体详情如下:
包路径:org.eclipse.swt.widgets.MenuItem
类名称:MenuItem
方法名:setImage
[英]Sets the receiver's image to the argument, which may be null indicating that no image should be displayed.
Note: This operation is a HINT and is not supported on platforms that do not have this concept (for example, Windows NT). Furthermore, some platforms (such as GTK2), cannot display both a check box and an image at the same time. Instead, they hide the image and display the check box. Some platforms (such as GTK3) support images alongside check boxes.
[中]将接收器的图像设置为参数,该参数可能为空,表示不应显示图像。
注意:此操作是一个提示,在没有此概念的平台(例如Windows NT)上不受支持。此外,某些平台(如GTK2)不能同时显示复选框和图像。相反,它们会隐藏图像并显示复选框。一些平台(如GTK3)支持复选框旁边的图像。
代码示例来源:origin: pentaho/pentaho-kettle
addNewItem.setImage( imageAddScript );
addNewItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
copyItem.setImage( imageDuplicateScript );
copyItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
setActiveScriptItem.setImage( imageActiveScript );
setActiveScriptItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
setStartScriptItem.setImage( imageActiveStartScript );
setStartScriptItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
setEndScriptItem.setImage( imageActiveEndScript );
setEndScriptItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
MenuItem setRemoveScriptItem = new MenuItem( cMenu, SWT.PUSH );
setRemoveScriptItem.setText( BaseMessages.getString( PKG, "ScriptValuesDialogMod.RemoveScriptType" ) );
setRemoveScriptItem.setImage( imageInactiveScript );
setRemoveScriptItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
代码示例来源:origin: pentaho/pentaho-kettle
MenuItem item = new MenuItem( menu, SWT.NONE );
item.setText( Const.NVL( stream.getDescription(), "" ) );
item.setImage( getImageFor( stream ) );
item.addSelectionListener( new SelectionAdapter() {
@Override
代码示例来源:origin: pentaho/pentaho-kettle
addDeleteItem.setImage( imageDeleteScript );
addDeleteItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
代码示例来源:origin: caoxinyu/RedisClient
menuItem_1.setImage(strImage);
menuItem_2.setImage(listImage);
menuItem_3.setImage(setImage);
mntmSortedSet.setImage(zsetImage);
mntmHash_1.setImage(hashImage);
代码示例来源:origin: BiglySoftware/BiglyBT
public static void setMenuItemImage(final MenuItem item, final Image image) {
if (!Constants.isOSX)
item.setImage(image);
}
代码示例来源:origin: caoxinyu/RedisClient
mntmString.setText(i18nFile.getText(I18nFile.STRING) + "\tAlt+1");
mntmString.setAccelerator(SWT.ALT + '1');
mntmString.setImage(strImage);
mntmList.setText(i18nFile.getText(I18nFile.LIST) + "\tAlt+2");
mntmList.setAccelerator(SWT.ALT + '2');
mntmList.setImage(listImage);
mntmSet.setText(i18nFile.getText(I18nFile.SET) + "\tAlt+3");
mntmSet.setAccelerator(SWT.ALT + '3');
mntmSet.setImage(setImage);
mntmSortset.setText(i18nFile.getText(I18nFile.ZSET) + "\tAlt+4");
mntmSortset.setAccelerator(SWT.ALT + '4');
mntmSortset.setImage(zsetImage);
mntmHash.setText(i18nFile.getText(I18nFile.HASH) + "\tAlt+5");
mntmHash.setAccelerator(SWT.ALT + '5');
mntmHash.setImage(hashImage);
代码示例来源:origin: BiglySoftware/BiglyBT
@Override
public void imageDownloaded(Image image, String key, boolean returnedImmediately){
if ( image != null && returnedImmediately ){
m.setImage( image );
m.addDisposeListener(
new DisposeListener(){
@Override
public void widgetDisposed(DisposeEvent e){
ImageLoader.getInstance().releaseImage( key );
}
});
}
}
});
代码示例来源:origin: org.eclipse.egit/ui
private void createMenuItem(Menu menu, final Repository repository,
String currentBranch, final String fullName, String shortName) {
final MenuItem item = new MenuItem(menu, SWT.PUSH);
item.setText(shortName);
boolean checkedOut = currentBranch.equals(fullName);
if (checkedOut)
item.setImage(checkedOutImage);
else
item.setImage(branchImage);
item.setEnabled(!checkedOut);
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
BranchOperationUI.checkout(repository, fullName)
.start();
}
});
}
代码示例来源:origin: cbeust/testng-eclipse
protected void addActionToMenu(Menu parent, Action action, Image image) {
final ActionContributionItem item = new ActionContributionItem(action);
item.fill(parent, -1);
final MenuItem menuItem = (MenuItem) item.getWidget();
if (image != null) {
menuItem.setImage(image);
}
}
代码示例来源:origin: BiglySoftware/BiglyBT
/**
* <p>
* Set a MenuItem's image with the given ImageRepository key. In compliance with platform
* human interface guidelines, the images are not set under Mac OS X.
* </p>
* @param item SWT MenuItem
* @param repoKey ImageRepository image key
* @see <a href="http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGMenus/chapter_7_section_3.html#//apple_ref/doc/uid/TP30000356/TPXREF116">Apple HIG</a>
*/
public static void setMenuItemImage(final MenuItem item, final String repoKey) {
if (Constants.isOSX || repoKey == null) {
return;
}
ImageLoader imageLoader = ImageLoader.getInstance();
item.setImage(imageLoader.getImage(repoKey));
item.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
ImageLoader imageLoader = ImageLoader.getInstance();
imageLoader.releaseImage(repoKey);
}
});
}
代码示例来源:origin: org.eclipse.e4.ui.workbench.renderers/swt
public void handleEvent(Event event) {
// Ensure that this event is for a MMenuItem
if (!(event.getProperty(UIEvents.EventTags.ELEMENT) instanceof MMenuItem))
return;
MMenuItem itemModel = (MMenuItem) event
.getProperty(UIEvents.EventTags.ELEMENT);
MenuItem menuItem = (MenuItem) itemModel.getWidget();
// No widget == nothing to update
if (menuItem == null)
return;
String attName = (String) event
.getProperty(UIEvents.EventTags.ATTNAME);
if (UIEvents.UILabel.LABEL.equals(attName)) {
setItemText(itemModel, menuItem);
} else if (UIEvents.UILabel.ICONURI.equals(attName)) {
menuItem.setImage(getImage(itemModel));
}
}
};
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.cheatsheets
private int contributeRestartItem(Menu menu, int index) {
MenuItem item = new MenuItem(menu, SWT.PUSH, index++);
item.setText(Messages.RESTART_MENU);
item.setImage(CheatSheetPlugin.getPlugin().getImage(ICheatSheetResource.CHEATSHEET_RETURN));
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
viewer.restart();
}
});
return index;
}
代码示例来源:origin: org.xworker/xworker_swt
public static void applyMenuItem(ActionContext actionContext){
MenuItem control = (MenuItem) actionContext.get("widget");
Thing self = (Thing) actionContext.get("self");
//图
Image image = (Image) createResource(self.getString("image"),
"xworker.swt.graphics.Image", "imageFile", actionContext);
if(image != null){
control.setImage(image);
}
//是否激活
String enabled = self.getString("enabled");
if(enabled != null && !"".equals(enabled)) control.setEnabled(self.getBoolean("enabled"));
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.cheatsheets
private int contributeRestartMenuItem(Menu menu, int index) {
MenuItem item = new MenuItem(menu, SWT.PUSH, index++);
item.setText(Messages.RESTART_ALL_MENU);
item.setImage(CheatSheetPlugin.getPlugin().getImage(ICheatSheetResource.COMPOSITE_RESTART_ALL));
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (model != null) {
if (RestartAllAction.confirmRestart()) {
restart(null);
}
}
}
});
return index;
}
代码示例来源:origin: org.eclipse.egit/ui
private void addMenuItem(Menu parent, String itemName, Image image,
AbstractRebaseCommandHandler action, boolean isEnabled) {
MenuItem item = new MenuItem(parent, SWT.PUSH);
item.setImage(image);
item.setText(itemName);
item.setEnabled(isEnabled);
ExecutionEvent event = createExecutionEvent();
ItemSelectionListener selectionListener = new ItemSelectionListener(
action, event);
item.addSelectionListener(selectionListener);
}
代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui
public void fill(Menu menu, int index) {
MenuItem mi= new MenuItem(menu, SWT.RADIO, index);
String name= fWorkingSet.getLabel();
mi.setText("&" + fId + " " + name); //$NON-NLS-1$ //$NON-NLS-2$
if (fImage == null) {
ImageDescriptor imageDescriptor= fWorkingSet.getImage();
if (imageDescriptor != null)
fImage= imageDescriptor.createImage();
}
mi.setImage(fImage);
mi.setSelection(fWorkingSet.equals(fActionGroup.getWorkingSet()));
mi.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
IWorkingSetManager manager= PlatformUI.getWorkbench().getWorkingSetManager();
fActionGroup.setWorkingSet(fWorkingSet, true);
manager.addRecentWorkingSet(fWorkingSet);
}
});
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.tips.ui
private void startupMenuAboutToShow(final Menu menu) {
Arrays.asList(menu.getItems()).forEach(item -> item.dispose());
MenuItem item0 = new MenuItem(menu, SWT.CHECK);
item0.setText(Messages.TipComposite_1);
item0.setSelection(fTipManager.getStartupBehavior() == TipManager.START_DIALOG);
item0.addListener(SWT.Selection, event -> fTipManager.setStartupBehavior(TipManager.START_DIALOG));
item0.setImage(getStartupItemImage(TipManager.START_DIALOG));
MenuItem item1 = new MenuItem(menu, SWT.CHECK);
item1.setText(Messages.TipComposite_5);
item1.setSelection(fTipManager.getStartupBehavior() == TipManager.START_BACKGROUND);
item1.addListener(SWT.Selection, event -> fTipManager.setStartupBehavior(TipManager.START_BACKGROUND));
item1.setImage(getStartupItemImage(TipManager.START_BACKGROUND));
MenuItem item2 = new MenuItem(menu, SWT.CHECK);
item2.setText(Messages.TipComposite_6);
item2.setSelection(fTipManager.getStartupBehavior() == TipManager.START_DISABLE);
item2.addListener(SWT.Selection, event -> fTipManager.setStartupBehavior(TipManager.START_DISABLE));
item2.setImage(getStartupItemImage(TipManager.START_DISABLE));
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.tips.ui
private void loadActionMenu(Tip pTip) {
if (fActionMenu != null) {
fActionMenu.dispose();
}
fActionMenu = new Menu(fContentComposite.getShell(), SWT.POP_UP);
pTip.getActions().subList(1, pTip.getActions().size()).forEach(action -> {
MenuItem item = new MenuItem(fActionMenu, SWT.PUSH);
item.setText(action.getText());
item.setToolTipText(action.getTooltip());
item.setText(action.getText());
item.setImage(getActionImage(action.getTipImage()));
item.addListener(SWT.Selection, e -> runTipAction(action));
});
}
代码示例来源:origin: com.eclipsesource.tabris/tabris
private void addMenuItem( PageDescriptor pageDescriptor ) {
MenuItem item = new MenuItem( pageSwitcherMenu, SWT.PUSH );
item.setData( RWT.CUSTOM_VARIANT, CUSTOM_VARIANT_TABRIS_UI );
String title = pageDescriptor.getTitle();
item.setText( title == null ? "" : title );
item.setImage( getImage( uiParent.getDisplay(), pageDescriptor.getImage() ) );
item.setData( pageDescriptor );
item.addListener( SWT.Selection, new MenuItemSelectionListener() );
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.cheatsheets
private void createMenuItem(Menu menu, int index, final CheatSheetElement element, boolean bCheck) {
MenuItem mi = new MenuItem(menu, bCheck ? SWT.RADIO : SWT.PUSH, index);
mi.setText(element.getLabel(null));
String key;
if (element.isComposite()) {
key = ICheatSheetResource.COMPOSITE_OBJ;
} else {
key = ICheatSheetResource.CHEATSHEET_OBJ;
}
mi.setImage(CheatSheetPlugin.getPlugin().getImageRegistry().get(key));
mi.setSelection(bCheck);
mi.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
run(element, e);
}
});
}
内容来源于网络,如有侵权,请联系作者删除!