一、问题
在使用arcobjects for java进行arcgis二次开发时,工具栏添加自定义的工具后,工具呈现灰色且无法被点击。
二、解决方法
在自定义的类中实现ICommand接口,并重写isEnabled方法,返回值改为true就行。
public class AddLayer implements ICommand {
@Override
public void onClick() throws IOException, AutomationException {
}
@Override
public boolean isEnabled() throws IOException, AutomationException {
return true;
}
@Override
public boolean isChecked() throws IOException, AutomationException {
return false;
}
@Override
public String getName() throws IOException, AutomationException {
return "添加图层";
}
@Override
public String getCaption() throws IOException, AutomationException {
return "添加图层";
}
@Override
public String getTooltip() throws IOException, AutomationException {
return "添加图层";
}
@Override
public String getMessage() throws IOException, AutomationException {
return "给地图添加一个图层";
}
@Override
public String getHelpFile() throws IOException, AutomationException {
return null;
}
@Override
public int getHelpContextID() throws IOException, AutomationException {
return 0;
}
@Override
public int getBitmap() throws IOException, AutomationException {
return 0;
}
@Override
public String getCategory() throws IOException, AutomationException {
return null;
}
@Override
public void onCreate(Object o) throws IOException, AutomationException {
}
}