The core node you are trying to access is permanently deleted.
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(); } } }
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(); } } }
EDIT: I was able to get the Java Commands category to show up once using 1.6, but have not been able to reproduce it... I tried remaking the addin using the same steps, and it is missing once again... below are my steps using JRE 1.6:
[ATTACH=CONFIG]32689[/ATTACH]
[ATTACH=CONFIG]32690[/ATTACH]
[ATTACH=CONFIG]32691[/ATTACH]
[ATTACH=CONFIG]32692[/ATTACH]
[ATTACH=CONFIG]32693[/ATTACH]
Look at the source of your config.xml.
<ArcMap>
<Commands>
<Button ... in here is where you want to check the following:
</Commands>
1. The category value is correct.
2. The class value contains the full package name of the class, if you put your Button1 class in a package.
3. If you used an image for your button, make sure the path is correct.
A screenshot of your project expanded would help.
Your java source files are in a folder called: src or java ?
Did you place the Button1 class in a package of your own?
Such as:
My Project[INDENT]java (or src)[/INDENT]
[INDENT=2]your.package.name[/INDENT]
[INDENT=3]Button1.java
[/INDENT]
Also, the thing that is not the same in your environment is you have a value of "default" for the <AddInID> tag, whereas I have a value that looks like this:
<AddInID>473e3189-0145-1000-5000-0a09186f0000</AddInID>
The Add-in project wizzard places that value there for me, I don't do anything to generate it.
Why is that?
Ok, you solved it.
The class name in the config.xml needs to include your package name, which I said before.
In the config.xml gui or the source, change the class value to: my.pkg.Button1.java