好的,所以我创建了这样的图像:
Image deleteImage = new Image(viewer.getTable().getDisplay(),
Provider.PATH_TO_DELETE_ICON);
如何添加鼠标侦听器以便我知道何时单击图像?
这是我的标签提供程序类:
private class MyLabelProvider extends LabelProvider implements
ITableLabelProvider {
@Override
public Image getColumnImage(Object element, int columnIndex) {
if (columnIndex == 3) {
Image deleteImage = new Image(viewer.getTable().getDisplay(),
Provider.PATH_TO_DELETE_ICON);
return deleteImage;
}
if (columnIndex == 4) {
Image editImage = new Image(viewer.getTable().getDisplay(),
Provider.PATH_TO_EDIT_ICON);
return editImage;
} else
return null;
}
public String getColumnText(Object element, int index) {
Provider provider = (Provider) element;
switch (index) {
case 0:
return Integer.toString(provider.getId());
case 1:
return provider.getName();
case 2:
return provider.getBulstat();
default:
return "";
}
}
}