arcgissamples\scenario\MapViewer.java
/* Copyright 2010 ESRI * * All rights reserved under the copyright laws of the United States * and applicable international laws, treaties, and conventions. * * You may freely redistribute and use this sample code, with or * without modification, provided you include the original copyright * notice and use restrictions. * * See the use restrictions. * */ package arcgissamples.scenario; import java.awt.Dimension; import java.awt.Toolkit; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.IOException; import com.esri.arcgis.system.AoInitialize; import com.esri.arcgis.system.EngineInitializer; import com.esri.arcgis.system.esriLicenseProductCode; import com.esri.arcgis.system.esriLicenseStatus; public class MapViewer { public static void main (String[] args) throws IOException { EngineInitializer.initializeVisualBeans(); final AoInitialize aoInit = new AoInitialize(); initializeArcGISLicenses(aoInit); 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(); } static void initializeArcGISLicenses(AoInitialize aoInit) { try { AoInitialize ao = new AoInitialize(); if (ao.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeEngine) == esriLicenseStatus.esriLicenseAvailable) ao.initialize(esriLicenseProductCode.esriLicenseProductCodeEngine); else if (ao.isProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeArcView) == esriLicenseStatus.esriLicenseAvailable) ao.initialize(esriLicenseProductCode.esriLicenseProductCodeArcView); } catch (Exception e) {e.printStackTrace();} } }