Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am building a custom arcMap Addin button which onclick event tells info about selected features.

Following is my java class ---

public class Break extends Button {

 * Called when the button is clicked.
 * @exception java.io.IOException if there are interop problems.
 * @exception com.esri.arcgis.interop.AutomationException if the component throws an ArcObjects exception.
public void onClick() throws IOException, AutomationException {
    // TODO Auto-generated method stub

    MapBean mapBean = new MapBean();
        IMap map = mapBean.getMap();
        ISelection selection = map.getFeatureSelection();
        IEnumFeature enumFeature = (IEnumFeature)selection;
        IFeature feature = enumFeature.next();
        while (feature != null){
            System.out.println("FEATURE ID: " + feature.getOID());
            feature = enumFeature.next();
    catch (Exception e){

I implimented the button on ArcMap but nothing seems to work onclick event , might be its not getting the ArcMap at all.Could anybody tell how to resolve this issue.

Thanks in advance////

share|improve this question
add comment

1 Answer

Do you have:

public void init(IApplication app) throws IOException, AutomationException {
    this.app = app;

In your class?

You would need to have an application object in the class:

public class Break extends Button {
    private IApplication app; //<~ Add this too
    public void onClick() throws IOException, AutomationException {
share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.