kyanuk1

Creating ArcMap addins with Java SDk

Discussion created by kyanuk1 on Mar 20, 2014
Latest reply on Apr 9, 2014 by kyanuk1
Hello,

I am trying to create a simple Dockable Window addin using the ArcObjects Java SDK, but I am having a small issue.  I am able to create the addin successfully, with a button and dockable window, but when I install the addin using the .esriAddin installer, I cannot see the addin located in the category I chose... here is my code:

button:
import java.io.IOException;

import com.esri.arcgis.addins.desktop.Button;
import com.esri.arcgis.framework.IApplication;
import com.esri.arcgis.framework.IDockableWindow;
import com.esri.arcgis.framework.IDockableWindowManager;
import com.esri.arcgis.framework.IDockableWindowManagerProxy;
import com.esri.arcgis.interop.AutomationException;
import com.esri.arcgis.system.UID;


public final class btnMain extends Button
{
 private IDockableWindow docWin;

 @Override 
 public void init(IApplication app) {
     try {
         IDockableWindowManager dwm = new IDockableWindowManagerProxy(app);
         UID uid = new UID();
         uid.setValue("com.esri.arcgis.arcmap.addin.frmMain");
         docWin = dwm.getDockableWindow(uid);
     }
     catch (Exception e) {
         e.printStackTrace();
     }
 }
 
 @Override
 public void onClick() throws IOException, AutomationException {
  try {
         if (docWin != null) {
             docWin.show(!docWin.isVisible());
         }
     }
     catch (Exception e) {
         e.printStackTrace();
     }
 }
}


dockable window:
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;

import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

import com.esri.arcgis.addins.desktop.DockableWindow;
import com.esri.arcgis.arcmapui.IMxDocument;
import com.esri.arcgis.framework.IApplication;
import com.esri.arcgis.interop.AutomationException;


public final class frmMain extends DockableWindow
{
 private JButton jButton;
 private JPanel jPanel;
 private IApplication app;
 
 public static void main(String[] args){
 }

 @Override
 public Component createUI() {
  jButton = new JButton("Click Me!");
     jPanel = new JPanel();

     jButton.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
             JOptionPane.showMessageDialog(null, "Hello, World"); 
         } 
     });
     
     jPanel.setLayout(new BorderLayout());
     jPanel.add(jButton, BorderLayout.NORTH);

     return jPanel;
 }
 
 @Override 
 public void init(IApplication app) {
     this.app = app;
     try {
   IMxDocument mxDocument = (IMxDocument)app.getDocument();
  } catch (AutomationException e) {
   e.printStackTrace();
  } catch (IOException e) {
   e.printStackTrace();
  }
 }
}



Any help is greatly appreciated.

Thanks

Outcomes