Exception in thread "main" java.lang.RuntimeException: AutomationException: 0x80040112 -
at com.esri.arcgis.interop.Ocx.<init>(Unknown Source)
at com.esri.arcgis.controls.PageLayoutControl.<init>(Unknown Source)
at com.esri.arcgis.beans.pagelayout.PageLayoutBean.c(Unknown Source)
at com.esri.arcgis.beans.pagelayout.PageLayoutBean.<init>(Unknown Source)
at tryAndTest.MapViewerFrame.<init>(MapViewer.java:32)
at tryAndTest.MapViewer.main(MapViewer.java:69)
Caused by: AutomationException: 0x80040112 -
... 6 more
代码如下:(省去了import了)
class MapViewerFrame extends JFrame {
PageLayoutBean pageLayout;
MapBean map;
TOCBean toc;
ToolbarBean toolbar;
JLabel statusLabel;
public MapViewerFrame(){
setTitle("MapViewer");
pageLayout=new PageLayoutBean();
map=new MapBean();
toc=new TOCBean();
toolbar=new ToolbarBean();
statusLabel=new JLabel(" ");
}
private JPanel buildMapTOCPanel(){
JPanel leftPanel=new JPanel();
JPanel bottomPanel=new JPanel();
leftPanel.setLayout(new BorderLayout());
bottomPanel.setLayout(new BorderLayout());
bottomPanel.setPreferredSize(new Dimension(200,200));
bottomPanel.add(map, BorderLayout.CENTER);
leftPanel.add(toc,BorderLayout.CENTER);
leftPanel.add(bottomPanel,BorderLayout.SOUTH);
return leftPanel;
}
public void buildAndShow()throws IOException{
JPanel mapTOCPanel=buildMapTOCPanel();
this.getContentPane().add(toolbar,BorderLayout.NORTH);
this.getContentPane().add(pageLayout,BorderLayout.CENTER);
this.getContentPane().add(mapTOCPanel,BorderLayout.WEST);
this.getContentPane().add(statusLabel,BorderLayout.SOUTH);
this.setVisible(true);
}
}
public class MapViewer{
public static void main(String[] args)throws IOException{
EngineInitializer.initializeVisualBeans();
// String laf=UIManager.getSystemLookAndFeelClassName();
// UIManager.setLookAndFeel(laf);
final AoInitialize aoInit=new AoInitialize();
aoInit.initialize(esriLicenseProductCode.esriLicenseProductCodeEngine);
MapViewerFrame mapViewerFrame=new MapViewerFrame();
Dimension d=Toolkit.getDefaultToolkit().getScreenSize();
int x=d.width/6;
int y=d.height/6;
int width=d.width*2/3;
int height=d.height*2/3;
mapViewerFrame.setBounds(x,y,width,height);
mapViewerFrame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
try{
aoInit.shutdown();
}
catch(IOException ex){
ex.printStackTrace();
}
System.exit(0);
}
});
mapViewerFrame.buildAndShow();
}
}
------解决方案--------------------
你好,我也出了这个问题,是调用AO的那个XY_TO_Line的时候出现的,请问您的问题解决了吗,是怎么解决的?