Solved! Go to Solution.
I think x.Application should be set to the _mApplication windows handle, something like _mApplication.getHWnd() or whatever the syntax is for .NET.
public class Button1 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. */ @Override public void onClick() throws IOException, AutomationException { // TODO Auto-generated method stub GenericWindow genWindow = new GenericWindow(); genWindow.setApplicationByRef(app); genWindow.setName("Window 1"); genWindow.setTitle("Generic Window Test"); genWindow.putPosition(100, 100, 500, 500); genWindow.show(true); } @Override public void init(IApplication app) throws IOException, AutomationException { // TODO Auto-generated method stub super.init(app); this.app = app; mxDoc = (IMxDocument) app.getDocument(); map = mxDoc.getActiveView().getFocusMap(); } private IApplication app; private IMxDocument mxDoc; private IMap map; }
INFO::Using the following arguments to create the JVM -Djava.class.path=C:\Program Files (x86)\ArcGIS\Desktop10.0\\java\lib\arcobjects.jar -Xms64m -Xmx128m -Xss512k -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8013 INFO::Successfully created an instance of : com/esri/arcgis/addinframework/AddInFactory java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) Caused by: AutomationException: 0x80004005 - Unspecified error at com.esri.arcgis.arcmapui.GenericWindow.show(Unknown Source) at Button1.onClick(Button1.java:27) at com.esri.arcgis.addinframework.InternalButton.onClick(Unknown Source) ... 4 more SEVERE::CAUSE AutomationException: 0x80004005 - Unspecified error at com.esri.arcgis.arcmapui.GenericWindow.show(Unknown Source) at Button1.onClick(Button1.java:27) at com.esri.arcgis.addinframework.InternalButton.onClick(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597)
IGenericWindow x = new GenericWindowClass(); x.Application = _mApplication; x.PutPosition(100, 100, 200, 200);
I took out the line to show the window and I still got the window and no error message. What is the show(true) method for if you don't need it? Don't know. It obviously does not set the title like I asked it either...
I will ask, why use this? Why not create your own window using a JFrame or a .NET window, or why not even use a dockable window?
Adding buttons to existing controls, such as the Edit Attributes Window? I have not seen this done using Add-ins.
Then what about putting existing ESRI controls together with other .NET control (such as a button)?
Thank you!